解决163/sohu/sina不能够收到PHP MAIL函数发出邮件的问题

前端之家收集整理的这篇文章主要介绍了解决163/sohu/sina不能够收到PHP MAIL函数发出邮件的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="codetitle"><a style="CURSOR: pointer" data="18572" class="copybut" id="copybut18572" onclick="doCopy('code18572')"> 代码如下:

<div class="codebody" id="code18572">
// multiple recipients
$to = 'aidan@example.com' . ','; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '


Birthday Reminders for August


Here are the birthdays upcoming in August!


<table>
<tr>
PersonDayMonthYear
</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>


';
// 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,发现奇怪的内容
<div class="codetitle"><a style="CURSOR: pointer" data="10286" class="copybut" id="copybut10286" onclick="doCopy('code10286')"> 代码如下:
<div class="codebody" id="code10286">
Mar 1 11:28:03 @L_502_2@ 代码如下:
<div class="codebody" id="code88260">
Feb 25 23:44:59 <a title="shaohui" href="http://www.shaohui.org" target="_blank">shaohui 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函数原来也是可以伪造发件人的。
<div class="codetitle"><a style="CURSOR: pointer" data="27781" class="copybut" id="copybut27781" onclick="doCopy('code27781')"> 代码如下:
<div class="codebody" id="code27781">
bool mail ( string $to,string $subject,string $message [,string $additional_headers [,string $additional_parameters ]] )

在第六个参数additional_parameters使用额外的参数"-f sender_addr@mydomain.com",问题就解决了。

原文链接:https://www.f2er.com/php/29292.html
PHP函数函数函数邮件邮件

猜你在找的PHP相关文章