无法通过AWS SES发送AMP邮件问题求助
AWS SES发送AMP邮件仅显示纯文本的修复方案
问题根源
你的原始邮件存在三个核心问题:
- MIME结构混乱:
text/html部分被放在了结束分隔线之后,text/x-amp-html的位置不符合规范,导致邮件客户端无法识别多格式内容。 - AMP代码不完整:缺少必要的
<head>、<body>闭合标签,CSS样式未包裹在AMP要求的<style amp4email>标签中,也没有引入AMP核心脚本。 - 格式换行错误:MIME头部与内容、分隔线与内容之间缺少必要的空行,解析器无法正确拆分各邮件部分。
修正后的完整原始邮件代码
Subject: Example MIME formatted AMP message MIME-Version: 1.0 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/html; charset="UTF-8" Hello World in HTML! --001a114634ac3555ae05525685ae Content-Type: text/x-amp-html; charset="UTF-8" <!doctype html> <html ⚡4email data-css-strict> <head> <meta charset="utf-8"> <style amp4email> body { visibility: visible; } </style> <script async src="https://cdn.ampproject.org/v0.js"></script> </head> <body> Hello World in AMP! </body> </html> --001a114634ac3555ae05525685ae--
关键注意事项
- MIME各部分必须按
text/plain→text/html→text/x-amp-html的顺序排列,且全部包裹在起始和结束分隔线内。 - 每个MIME头部(如
Content-Type)之后必须加一个空行,再写入对应内容,否则解析器会将头部和内容视为同一行,导致格式识别失败。 - AMP邮件必须引入核心脚本
<script async src="https://cdn.ampproject.org/v0.js"></script>,且样式必须放在<style amp4email>标签中,这是客户端渲染AMP内容的必要条件。 - 确保换行符使用LF(\n),部分邮件客户端对CRLF(\r\n)的兼容较差。
内容的提问来源于stack exchange,提问作者Shwe
相关产品推荐
相关产品推荐

