2013-05-01 70 views
1

首先,我正在修復現有的開源庫。雖然我知道人們發送HTML郵件時應該發送純文本版本的消息,但這不是一個最佳實踐問題。如果我不保持向後兼容性,他們將不會接受我的補丁。什麼是僅包含文本/ 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-- 

我想不通,如果這是一個最好的-practice或要求

我經歷過:

,但找不到任何信息。

回答

0

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

From: [email protected] 
To: [email protected] 
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; 

參考

+0

你對此有一個參考?我不懷疑它的工作原理 - 我已經能夠在這裏堵塞很多不同的內容類型,並且它仍然呈現正確。我只關心適當的標準。 – 2013-12-05 15:45:22

+0

@JonathanVanasco我已經添加了參考 – 2013-12-05 18:05:57

相關問題