我正在尝试使用gmail API从我的gmail帐户向自己发送我的第一封AMP电子邮件(至===发件人)。我发送的消息与AMP文档中提供的消息完全相同:https://amp.dev/documentation/guides-and-tutorials/learn/email-spec/amp-email-structure/,包括多部分/替代消息的所有Content-Type标头。但是,当我使用Chrome gmail客户端收到此消息时,我仅看到备用HTML版本和带有错误的横幅:“为什么不呈现动态内容?显示您的动态电子邮件时出现错误(INTERNAL_ERROR)。更多信息”。[C0 ]
附加信息:
[我使用gmail API发送消息,并使用js-base64对其进行编码:
const gmail = google.gmail({version:'v1',auth:oauth2Client});
以下代码中提供的消息本身(来自上面代码的电子邮件变量)。 exampleBody看起来很丑,我试图使用mimemessage npm包以及相同的INTERNAL_ERROR来生成它。这只是AMP电子邮件文档“原样”的示例: const base64EncodedEmail = Base64.encodeURI(email);
const status = gmail.users.messages
.send({
userId: mail_config.ADDRESS,
uploadType: 'multipart',
resource: {
raw: base64EncodedEmail
}
})
https://amp.dev/documentation/guides-and-tutorials/learn/email-spec/amp-email-structure/
我在这里想念什么?请帮助。
如果您尚未 const exampleBody = `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>
<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--`;
const email =
'From: ' +
my_address +
'\r\nTo: ' +
my_address +
'\r\nSubject: ' +
subject +
'\r\n' +
exampleBody;
发送动态电子邮件,则将无法发送。
要在Gmail上测试AMP,您可以使用registered with Google,它将动态电子邮件发送到您的gmail收件箱。
参考: