首页 > 解决方案 > AWS SES 发送多个 PDF 附件 Nodejs

问题描述

我正在尝试发送包含多个 PDF 附件的电子邮件。如何在 AWS SES nodejs 中执行此操作?

到目前为止,这是我的代码:

From: "test" <no-reply@email.com>\n
To: test@email.com\n
Subject: Test Subject\n
MIME-Version: 1.0\n
Content-Type: multipart/mixed; boundary=\"NextPart\"\n\n
--NextPart\n
Content-Type: text/html; charset=us-ascii\n\n
This is the body of the email.\n\n
--NextPart\n
Content-Type: application/octet-stream;\n
Content-Transfer-Encoding: base64\n
Content-Disposition: attachment; filename=\"attachment.pdf\"\n\n
BASE64 OF PDF HERE
--NextPart

到目前为止,上面的代码正在运行,但是我想发送多个附件。谢谢你。

标签: node.jsamazon-web-servicesamazon-ses

解决方案


就我而言,问题是边界不匹配,例如:

--NextPart
Content-Type: text/html; charset=us-ascii\n\n
This is the body of the email.\n\n

--NextPart
Content-Type: application/octet-stream;\n
Content-Transfer-Encoding: base64\n
Content-Disposition: attachment; filename=\"attachment.pdf\"\n\n
BASE64 OF PDF HERE

--NextPartBlaBla
Content-Type: application/octet-stream;\n
Content-Transfer-Encoding: base64\n
Content-Disposition: attachment; filename=\"missed-attachment.pdf\"\n\n
BASE64 OF PDF HERE

因此,请注意边界。


推荐阅读