Copy Code code as follows:
Multiple recipients
$to = ' aidan@example.com '. ', '; Note the comma
$to. = ' wez@example.com ';
Subject
$subject = ' Birthday reminders for August ';
Message
$message = '
<title>birthday Reminders for august</title>
<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>
';
To send HTML mail, the Content-type header must is 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);
Look at SendMail's Maillog and find strange content.
Copy Code code as follows:
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
However, if I use the Linux Shell Mail command to be able to send a successful, but add a-f parameter to forge the sender. This is the only difference, so maillog one of the fields ctladdr display is not the same. No longer an Apache user, I suspect that 163 of other domestic mail service providers have handled all of the Apache users ' emails as junk mail.
Copy Code code as follows:
Feb 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
Root found, so the problem is very well solved, check the PHP manual, found that mail function is also can forge the sender.
Copy Code code as follows:
BOOL Mail (string $to, String $subject, String $message [, String $additional _headers [, String $additional _parameters ]] )
The problem is solved by using the extra parameter "-F sender_addr@mydomain.com" in the sixth parameter additional_parameters.