解决163/sohu/sina不能够收到PHP MAIL函数发出邮件的问题
网游之震撼,天下枭雄笔趣阁,开业软文
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'birthday reminders for august';
// message
$message = '
<html>
<head>
<title>birthday reminders for august</title>
</head>
<body>
<p>here are the birthdays upcoming in august!</p>
<table>
<tr>
<th>person</th><th>day</th><th>month</th><th>year</th>
</tr>
<tr>
<td>joe</td><td>3rd</td><td>august</td><td>1970</td>
</tr>
<tr>
<td>sally</td><td>17th</td><td>august</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// to send html mail, the content-type header must be set
$headers = 'mime-version: 1.0' . "\r\n";
$headers .= 'content-type: text/html; charset=iso-8859-1' . "\r\n";
// additional headers
$headers .= 'to: mary <mary@example.com>, kelly <kelly@example.com>' . "\r\n";
$headers .= 'from: birthday reminder <birthday@example.com>' . "\r\n";
$headers .= 'cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'bcc: birthdaycheck@example.com' . "\r\n";
// mail it
mail($to, $subject, $message, $headers);
查看sendmail的maillog,发现奇怪的内容。
mar 1 11:28:03 <a title="shaohui" href="http://www.shaohui.org" target="_blank">shaohui</a>.org sendmail[27526]: n213s1xc027524: to=<shaohui_1983@163.com>, ctladdr=<shaohui@shaohui.org> (500/500), delay=00:00:02, xdelay=00:00:01, mailer=esmtp, pri=150812, relay=163mx03.mxmail.netease.com. [220.181.12.72], dsn=5.0.0, stat=service unavailable
但是,如果我使用linux shell 的mail命令是可以发送成功的,不过多加了一条-f 参数伪造发件人。这是唯一的不同,于是maillog 的其中一个字段ctladdr显示也不一样。不再是apache用户,我怀疑163等国内的邮件服务提供商,把所有的apache的用户的邮件当成垃圾邮件处理掉了。
feb 25 23:44:59 <a title="shaohui" href="http://www.shaohui.org" target="_blank">shaohui</a> sendmail[13067]: n1pfixh4013067: to=shaohui_1983@163.com, ctladdr=contact@shaohui.org (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30869, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=sent (n1pfixdx013068 message accepted for delivery)
根源找到,于是问题就很好解决了,查一下php的手册,发现mail函数原来也是可以伪造发件人的。
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
在第六个参数additional_parameters使用额外的参数"-f sender_addr@mydomain.com", 问题就解决了。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
相关文章:
-
-
-
-
Yii框架应用组件用法实例分析
本文实例讲述了yii框架应用组件用法。分享给大家供大家参考,具体如下:应用组件 应用主体是, 它部署一组提供各种不同功能的 应用组件 来处理请求。 例如,url...
[阅读全文]
-
-
-
-
-
Yii 框架入口脚本示例分析
本文实例讲述了yii 框架入口脚本。分享给大家供大家参考,具体如下:入口脚本入口脚本是应用启动流程中的第一环, 一个应用(不管是网页应用还是控制台应用)只有一个...
[阅读全文]
-
PHP强制转化的形式整理
php强制转化有几种形式php强制转化有3种形式:1、在要转换的变量之前加上用括号括起来的目标类型;2、使用转强函数,如“intval()”,“strval()...
[阅读全文]
-
php7 新增功能实例总结
本文实例总结了php7 新增功能。分享给大家供大家参考,具体如下:一、核心 增加了group use语法声明。rfc: https://wiki.php.ne...
[阅读全文]
网友评论