【发布时间】:2019-05-07 13:09:35
【问题描述】:
我最近了解了 AMP 电子邮件,发现它很有趣,并尝试了一个使用 nodemailer 包的 nodejs 示例。
这个包已经包含一个选项“amp”来发送特定于 AMP 的电子邮件,但是我无法让它工作。
AMP 版本的电子邮件非常简单,它不包含任何 xhr 请求。 下面是我向特定电子邮件地址发送电子邮件的代码。
let transporter = nodeMailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: "validuser@gsuiteBusinessdomain.com",
pass: "validpassword"
},
});
let mailOptions = {
from: 'sender@gsuiteBusinessdomain.com', // sender address
to: "enduser@gsuiteBusinessdomain.com", // list of receivers
subject: "test subject", // Subject line
text: " basic text body example ", // plain text body
html: '<b>basic html body example</b>', // html body
amp: `<!--
Below is the mininum valid AMP4EMAIL document. Just type away
here and the AMP Validator will re-check your document on the fly.
-->
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<style amp4email-boilerplate>body{visibility:hidden}</style>
</head>
<body>
Hello, AMP4EMAIL world.
</body>
</html>`
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
});
另外,我尝试在 C# 中使用“MailKit”包,但不确定如何在此处设置 AMP 版本。我在 message.body 部分添加了我的 AMP 版本 MimeMessage 类。
message.Body = new TextPart(TextFormat.RichText)
{
Text = @"<!-- ........
我确信有一些非常小的东西我错过了但无法弄清楚。 有人可以看看并指导我上面的代码出了什么问题吗?
【问题讨论】:
标签: node.js c#-4.0 nodemailer mailkit amp-email