PHP 邮件 multipart/mixed 切断 Outlook 2010
PHP mail multipart/mixed cut off Outlook 2010
我正在开发一个使用 PHP 的邮件系统。我非常接近完成,因为除 Outlook 外一切正常(我目前正在 Windows 7 上在 Outlook 2010 中进行测试)。
e-mail是multipart/mixed
;它包含 multipart/alternative
组 HTML 和 plain-text 备选方案和可选附件。一切都已正确发送,如果我在 Gmail 中查看原始 headers,它看起来应该是这样。但是,如果我在 Outlook 中检查原始 headers,它会在 multipart/mixed
声明之后切断任何内容。我在此处包括了 headers。我简化了它们;剥离实际的纯文本,html,电子邮件地址,并简化边界。 Gmail 显示给我的headers,看起来有点像这样:
(... information about receiving by the server ...)
To: "Hidden recipients" <noreply@domain.com>
Subject: Een BCC
From: "My Name"<my@email.com>
Reply-To: my@email.com
Date: Sun, 19 Jul 2015 14:16:31 +0000
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="PHP-mixed"
This is a message with multiple parts in MIME format.
--PHP-mixed
Content-Type: multipart/alternative; boundary="PHP-alt"
--PHP-alt
Content-type:text/plain;charset=utf-8
Content-Transfer-Encoding: quoted-printable
... here's the plain text alternative
--PHP-alt
Content-type: text/html;charset=utf-8
Content-Transfer-Encoding: quoted-printable
... here's the html-formatted text
--PHP-alt--
--PHP-mixed--
Outlook 显示给我的 headers,看起来有点像这样:
(... information about receiving by the server ...)
To: "Hidden recipients" <noreply@domain.com>
Subject: Een BCC
From: "My Name"<my@email.com>
Reply-To: my@email.com
Date: Sun, 19 Jul 2015 14:16:31 +0000
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="PHP-mixed"
我的问题是,这是怎么发生的,我该如何解决这个问题?为什么 Gmail 运行良好,而 Outlook 却不行?
Outlook 显示它应该显示的内容:MIME headers。它不显示整个 MIME 消息。 Outlook 是否正确显示邮件本身?
为了参考遇到与我类似的问题的人,我 post 这个答案。由于许多其他与通过 PHP 状态发送邮件相关的 SO 问题,建议使用其他库。存在许多库,您可以在这些库中选择要实现的库。
正如马里奥在这个问题的评论中所说,非常推荐使用库来发送更高级的电子邮件!对我来说,编写正确的 headers 是一件很痛苦的事情,而这些库是 easy-to-use,与构建自己的“邮件库”相比,您最终可能会得到更好的结果。
- SwiftMailer
- PHPMailer(我的申请选择了这个)
- 可能还有其他一些.. 只需查询 Google 您需要的内容。
我觉得 PHPMailer 很容易实现;只需将代码复制到我的目录就可以了!我不确定 SwiftMailer,但我想它的工作原理类似。
底线:不要固执,使用库! :-)
我正在开发一个使用 PHP 的邮件系统。我非常接近完成,因为除 Outlook 外一切正常(我目前正在 Windows 7 上在 Outlook 2010 中进行测试)。
e-mail是multipart/mixed
;它包含 multipart/alternative
组 HTML 和 plain-text 备选方案和可选附件。一切都已正确发送,如果我在 Gmail 中查看原始 headers,它看起来应该是这样。但是,如果我在 Outlook 中检查原始 headers,它会在 multipart/mixed
声明之后切断任何内容。我在此处包括了 headers。我简化了它们;剥离实际的纯文本,html,电子邮件地址,并简化边界。 Gmail 显示给我的headers,看起来有点像这样:
(... information about receiving by the server ...)
To: "Hidden recipients" <noreply@domain.com>
Subject: Een BCC
From: "My Name"<my@email.com>
Reply-To: my@email.com
Date: Sun, 19 Jul 2015 14:16:31 +0000
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="PHP-mixed"
This is a message with multiple parts in MIME format.
--PHP-mixed
Content-Type: multipart/alternative; boundary="PHP-alt"
--PHP-alt
Content-type:text/plain;charset=utf-8
Content-Transfer-Encoding: quoted-printable
... here's the plain text alternative
--PHP-alt
Content-type: text/html;charset=utf-8
Content-Transfer-Encoding: quoted-printable
... here's the html-formatted text
--PHP-alt--
--PHP-mixed--
Outlook 显示给我的 headers,看起来有点像这样:
(... information about receiving by the server ...)
To: "Hidden recipients" <noreply@domain.com>
Subject: Een BCC
From: "My Name"<my@email.com>
Reply-To: my@email.com
Date: Sun, 19 Jul 2015 14:16:31 +0000
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="PHP-mixed"
我的问题是,这是怎么发生的,我该如何解决这个问题?为什么 Gmail 运行良好,而 Outlook 却不行?
Outlook 显示它应该显示的内容:MIME headers。它不显示整个 MIME 消息。 Outlook 是否正确显示邮件本身?
为了参考遇到与我类似的问题的人,我 post 这个答案。由于许多其他与通过 PHP 状态发送邮件相关的 SO 问题,建议使用其他库。存在许多库,您可以在这些库中选择要实现的库。
正如马里奥在这个问题的评论中所说,非常推荐使用库来发送更高级的电子邮件!对我来说,编写正确的 headers 是一件很痛苦的事情,而这些库是 easy-to-use,与构建自己的“邮件库”相比,您最终可能会得到更好的结果。
- SwiftMailer
- PHPMailer(我的申请选择了这个)
- 可能还有其他一些.. 只需查询 Google 您需要的内容。
我觉得 PHPMailer 很容易实现;只需将代码复制到我的目录就可以了!我不确定 SwiftMailer,但我想它的工作原理类似。
底线:不要固执,使用库! :-)