How to format an email that Hotmail / Outlook is h

2020-03-18 20:34发布

$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", $subject, $body, $headers, "-f admin@myserver.com");

Emails send fine to Gmail but are always rejected by Hotmail with this error:

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).

Message ID header is generated automatically by the server but it doesn't help to supply one manually either.

Why isn't Hotmail happy?

Mail server has SPF record, reverse DNS, is not blacklisted and passes all checks at mxtoolbox.com.

4条回答
Rolldiameter
2楼-- · 2020-03-18 21:19

If you're using WordPress, you can look up plugin for Hotmail/Outlook friendly emailing capability.

However if it is a standalone script you might wanna look into Microsoft's official answer to this query on the URL : http://answers.microsoft.com/en-us/outlook_com/forum/oemail-osend/why-are-the-emails-sent-to-microsoft-account/b64e3e4a-0d93-40c8-8e28-4be849012f9c

In-short Email-Server provider has to fill this form (once) : https://support.live.com/eform.aspx?productKey=edfsmsbl3&ct=eformts&wa=wsignin1.0&scrx=1

In order to get their emails accepted by Hotmail/Outlook.

查看更多
小情绪 Triste *
3楼-- · 2020-03-18 21:21

The From header is invalid. It must have the following syntax:

From: "name" <email-address>

In your case:

From: "Testing Site" <admin@myserver.com>

The same goes for your Reply-To header:

Reply-To: "Testing Site" <admin@myserver.com>

Which you can omit if it's the same as the From header (like in your case).

PS: RFC 2822 doesn't state that the display-name in an address should be quoted. In other words: the following 3 headers should all work:

From: "Testing Site" <admin@myserver.com>
From: 'Testing Site' <admin@myserver.com>
From: Testing Site <admin@myserver.com>
查看更多
姐就是有狂的资本
4楼-- · 2020-03-18 21:26

Using the PHPMailer library to send mail instead of the mail() function has finally sorted this problem and is the working solution for me. Answer by Jasper N. Brouwer probably more correctly answers the question though I've not had a chance to try it.

萌系小妹纸
5楼-- · 2020-03-18 21:29

1 ) Go to SPF record wizard

2) create a new SPF record for your DNS domain
3) Add that DNS record to your domain's DNS
4) if you fail somewhere in the process, read the detailed SPF record specification

After you complete this process HOTMAIL will be happy with your email.

查看更多
登录 后发表回答