將 AMP 新增至現有電子郵件
重要事項:本文件不適用於您目前選取的格式 stories!
AMP 電子郵件格式會嵌入為新的 MIME 零件。如果您的電子郵件傳送給支援 AMP 電子郵件的供應商,就會顯示電子郵件;如果沒有,請別擔心!供應商會顯示您的 HTML 或純文字備用版本。請按照本指南將 AMP 新增至您的電子郵件。
包含 AMP MIME 零件
電子郵件的結構為 MIME 樹狀結構,其中包含電子郵件訊息內文和任何附件。若要將 AMP 新增至您的電子郵件,您需要新增內容類型為 text/x-amp-html
的新 MIME 零件。
AMP MIME 零件必須巢狀於 multipart/alternative
節點下,並與現有的 text/html
或 text/plain
零件並存。這樣可確保電子郵件訊息會在所有用戶端上呈現。
From: Person A <persona@example.com>
To: Person B <personb@example.com>
Subject: An AMP email!
Content-Type: multipart/alternative; boundary="001a114634ac3555ae05525685ae"
--001a114634ac3555ae05525685ae
Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes
Hello World in plain text!
--001a114634ac3555ae05525685ae
Content-Type: text/x-amp-html; charset="UTF-8"
<!doctype html>
<html ⚡4email data-css-strict>
<head>
<meta charset="utf-8">
<style amp4email-boilerplate>body{visibility:hidden}</style>
<script async src="https://cdn.ampproject.org/v0.js"></script>
</head>
<body>
Hello World in AMP!
</body>
</html>
--001a114634ac3555ae05525685ae--
Content-Type: text/html; charset="UTF-8"
<span>Hello World in HTML!</span>
--001a114634ac3555ae05525685ae
部分電子郵件用戶端只會呈現最後一個 MIME 零件。為了確保電子郵件能正確呈現,請將
text/x-amp-html
MIME 零件放在 text/html
MIME 零件之前。當收件者轉寄或回覆 AMP 電子郵件時,會發生什麼事?
當使用者轉寄或回覆 AMP 電子郵件時,系統會移除 MIME 樹狀結構的 text/x-amp-html
零件。這就是為什麼即使在將 AMP 電子郵件傳送給支援 MIME 類型的用戶端時,仍務必在 HTML 零件中提供替代內容。
-
作者: @CrystalOnScript