node.js - 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
到目前为止,上面的代码正在运行,但是我想发送多个附件。谢谢你。
解决方案
就我而言,问题是边界不匹配,例如:
--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
因此,请注意边界。
推荐阅读
- java - 如何在所有情况下只装箱一次
- angular - 内容类型应用程序/json的角度发布请求不起作用
- html - 如何使用按钮将单选按钮链接到页面
- node.js - 在 React 中使用 SASS @use 规则
- java - Java lambda 中括号和箭头 (->) 之间的变量是什么?
- python - 关于 python 和 C++ 之间的编码问题
- fortran - 为什么 Fortran 写入 fort.x?
- java - 使用 Spring Boot 2.2 访问应用程序文件夹之外的静态文件
- html - 在移动设备上调整 Bootstrap 4 卡片图像大小
- tensorflow - tensorflow:只能在 val_loss 可用的情况下保存最佳模型