1

首先,我正在修复一个现有的开源库。虽然我知道人们在发送 html 电子邮件时应该发送纯文本版本的消息,但这不是最佳实践问题。如果我不保持向后兼容性,他们就不会接受我的补丁。

我试图弄清楚如何最好地处理只发送 html 电子邮件的情况。

该库当前生成以下内容:

MIME-Version: 1.0
Content-Type: text/html;

Hello, World

但是我在收件箱中看到的每条仅 html 的消息都显示:

MIME-Version: 1.0
Content-Type: multipart/alternative; 
    boundary="----=_Part_1935495_1732146301.1367384830372"

----=_Part_1935495_1732146301.1367384830372
Content-Type: text/html;

Hello, World
----=_Part_1935495_1732146301.1367384830372--

我不知道这是最佳实践还是要求

我经历过:

但找不到任何信息。

4

1 回答 1

0

使用Content-Type: Multipart/related; type=Text/HTML

From: user1@example.com
To: user2@example.com
Subject: An example
Mime-Version: 1.0
Content-Base: http://www.example.com
Content-Type: Multipart/related; boundary="boundary-example-1";type=Text/HTML

--boundary-example-1
Content-Type: Text/HTML; charset=ISO-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE

... text of the HTML document, which might contain a hyperlink
to the other body part, for example through a statement such as:
<IMG SRC="/images/ie5.gif" ALT="Internet Explorer logo">
Example of a copyright sign encoded with Quoted-Printable: =A9
Example of a copyright sign mapped onto HTML markup: &#168;

参考

于 2013-12-05T03:39:34.953 回答