$body = 'This is a test'; $subject = 'Confirmation'; $headers = 'From: Testing Site' . "\r\n"; $headers .= 'Reply-To: admin@myserver.com' . "\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html;charset=iso-8859-1' . "\r\n"; $headers .= 'X-Mailer: PHP/' . PHPversion(). "\r\n"; $headers .= 'Delivery-Date: ' . date("r") . "\r\n"; //$headers .= 'Message-Id: <20140316055950.DA8ED58A13CE@myserver.com>' . "\r\n"; mail("example@hotmail.com",$subject,$body,$headers,"-f admin@myserver.com"); mail("example@gmail.com","-f admin@myserver.com");
电子邮件向Gmail发送正常邮件但Hotmail始终拒绝此错误:
host mx1.hotmail.com[65.55.33.119] said: 550 5.7.0 (COL0-MC5-F28)
Message could not be delivered. Please ensure the message is RFC 5322
compliant. (in reply to end of DATA command).
为什么Hotmail不开心?
From标头无效.它必须具有以下语法:
From: "name" <email-address>
在你的情况下:
From: "Testing Site" <admin@myserver.com>
Reply-To: "Testing Site" <admin@myserver.com>
如果它与From标题相同(如你的情况),你可以省略它.
PS:RFC 2822未声明应引用地址中的显示名称.换句话说:以下3个标题应该全部有效:
From: "Testing Site" <admin@myserver.com> From: 'Testing Site' <admin@myserver.com> From: Testing Site <admin@myserver.com>