use*_*109 10 php email outlook smtp dkim
我有一个邮件服务器与SPF,DKIM和反向DNS配置良好.我可以使用以下内容向Outlook.com发送电子邮件:
echo "This is only a test" | mail username@outlook.com
Run Code Online (Sandbox Code Playgroud)
当我尝试使用相同的服务器通过PHP发送电子邮件时,会出现问题:
$header .= "Return-Path: Some User <mailsender@mydomain.com>\r\n";
$header .= "From: Some User <mailsender@mydomain.com>\r\n";
$header .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "User-Agent: Some User Mail Sender\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n";
mail("usernama@outlook.com","My title", "Message body", $header);
Run Code Online (Sandbox Code Playgroud)
我尝试使用appmaildev.com验证我的消息,报告说:
DKIM result: fail (wrong body hash: <*** body hash ***>)
Run Code Online (Sandbox Code Playgroud)
即使出现此错误,Outlook.com也表示已通过DKIM验证,但PHP邮件功能发送的所有邮件都会转到垃圾邮件文件夹.以下是通过Bash和PHP直接发送的消息示例:http://pastebin.com/ndXJszic
谁能帮我?
谢谢.
编辑从标题中 删除\ r \n后,DKIM正文哈希错误消失了.但我还是无法向Outlook发送电子邮件......
这可能是一个权限问题。
mail您的 Web 服务器通常以与在命令行上使用时不同的用户身份运行,因此设置From:标头将在外发电子邮件中创建额外的警告标头。
您可以在服务器上修改一个名为/etc/mail/trusted-users. 确保该用户apache(或运行 php 脚本的任何用户)出现在该文件中;如果没有,请添加用户名,然后重新加载sendmail。
示例内容/etc/mail/trusted-users:
# trusted-users - users that can send mail as others without a warning
# apache, mailman, majordomo, uucp, are good candidates
apache
Run Code Online (Sandbox Code Playgroud)