Solve the problem that 163sohusina cannot receive an email from the PHPMAIL function. Copy the code as follows: multiplerecipients $ toaidan@example.com.,; notethecomma $ to.wez@example.com; subject $ subjectBirthdayRemindersforAugust
The code is as follows:
// 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!
Person |
Day |
Month |
Year |
Joe |
3rd |
August |
1970 |
Sally |
17th |
August |
1973 |
';
// To send HTML mail, the Content-type header must be set
$ Headers = 'Mime-Version: 100'. "\ r \ n ";
$ Headers. = 'content-type: text/html; charset = ISO-8859-1 '. "\ r \ n ";
// Additional headers
$ Headers. = 'To: Mary , Kelly '. "\ R \ n ";
$ Headers. = 'from: Birthday Reminder '. "\ R \ n ";
$ Headers. = 'http: birthdayarchive@example.com '. "\ r \ n ";
$ Headers. = 'bcc: birthdaycheck@example.com '. "\ r \ n ";
// Mail it
Mail ($ to, $ subject, $ message, $ headers );
Check the maillog of sendmail and find strange content.
The code is as follows:
Mar 1 11:28:03 shaohui.org sendmail [27526]: n213S1Xc027524: to = , Ctladdr = (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 mail command of Linux Shell, it can be sent successfully, but I add a-f parameter to forge the sender. This is the only difference, so the ctladdr field in maillog is different. I am no longer an apache user. I suspect that 163 and other domestic email service providers have disposed of all apache users' emails as spam.
The code is as follows:
Feb 25 23:44:59 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)
The root cause is found, so the problem is well solved. check the php manual and find that the mail function can also forge the sender.
The code is as follows:
Bool mail (string $ to, string $ subject, string $ message [, string $ additional_headers [, string $ additional_parameters])
When the sixth parameter additional_parameters uses the additional parameter "-f sender_addr@mydomain.com", the problem is solved.
The http://www.bkjia.com/PHPjc/319905.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/319905.htmlTechArticle code is as follows: // multiple recipients $ to = 'Aidan @ example.com '. ','; // note the comma $. = 'wez @ example.com '; // subject $ subject = 'birthday Reminders for August...