I have a mail server working well with SPF, DKIM and reverse DNS configured. I can send e-mails to Outlook.com using something like:
echo "This is only a test" | mail [email protected]
The problem occurs when I try to send e-mails via PHP using the same server:
$header .= "Return-Path: Some User <[email protected]>\r\n";
$header .= "From: Some User <[email protected]>\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("[email protected]","My title", "Message body", $header);
I tried to verify my message using appmaildev.com and the report says:
DKIM result: fail (wrong body hash: <*** body hash ***>)
Even with this error, Outlook.com says it passed DKIM verification, but all messages sent by PHP mail function go to junk folder. Here are examples of messages sent directly via Bash and via PHP: http://pastebin.com/ndXJszic
Can anyone help me?
Thanks.
EDIT After removing \r from headers, the DKIM body hash error is gone. But I still can't send e-mails to Outlook...