沃梦达 / 编程问答 / php问题 / 正文

如何格式化 Hotmail/Outlook 满意的电子邮件?

How to format an email that Hotmail / Outlook is happy with?(如何格式化 Hotmail/Outlook 满意的电子邮件?)

本文介绍了如何格式化 Hotmail/Outlook 满意的电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$body = 'This is a test';
    $subject = 'Confirmation';
$headers = 'From: Testing Site' . "
";
$headers .= 'Reply-To: admin@myserver.com' . "
";
$headers .= 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html;charset=iso-8859-1' . "
";
$headers .= 'X-Mailer: PHP/' . phpversion(). "
";
$headers .= 'Delivery-Date: ' . date("r") . "
";
//$headers .= 'Message-Id: <20140316055950.DA8ED58A13CE@myserver.com>' . "
";

mail("example@hotmail.com", $subject, $body, $headers, "-f admin@myserver.com");
mail("example@gmail.com", $subject, $body, $headers, "-f admin@myserver.com");

电子邮件可以正常发送到 Gmail,但总是被 Hotmail 拒绝并出现此错误:

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

host mx1.hotmail.com[65.55.33.119] 说:550 5.7.0 (COL0-MC5-F28)无法传递消息.请确保消息是 RFC 5322合规.(回复DATA命令结束).

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

消息 ID 标头由服务器自动生成,但手动提供也无济于事.

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

为什么 Hotmail 不高兴?

Why isn't Hotmail happy?

邮件服务器有 SPF 记录、反向 DNS、未列入黑名单并通过 mxtoolbox.com 的所有检查.

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

推荐答案

From 标头无效.它必须具有以下语法:

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

From: "name" <email-address>

就你而言:

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

同样适用于您的 Reply-To 标题:

The same goes for your Reply-To header:

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

如果它与 From 标头相同,你可以省略它(就像你的情况一样).

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

PS:RFC 2822 没有声明应该引用地址中的显示名称.换句话说:以下 3 个标题都应该有效:

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>

这篇关于如何格式化 Hotmail/Outlook 满意的电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何格式化 Hotmail/Outlook 满意的电子邮件?

基础教程推荐