【发布时间】:2020-07-15 22:06:47
【问题描述】:
我有一个由另一个函数生成的 pdf,它返回一个 Base64 字符串。然后我想将它附加到 Mailgun 电子邮件as attachment,即built into Meteor 和Mailgun。我看到有很多从file system 附加文件的示例,但我没有看到任何使用 Base64 的示例。
我有一个生成 Base64 字符串并用前缀连接的方法,以便convert Base64 to PDF:
//returns base64 string: looks like "YW55IGNhcm5hbCBwbGVhc3VyZQ=="
const base64AttachmentString = 'data:application/pdf;base64,' + generatePdfBase64();
import { Email } from "meteor/email";
Email.send({
to: "email@example.com",
from: "John Smith <johnsmith@example.com>",
subject: "Sending Base64 as PDF",
html: generatedHTMLTemplate,
attachment: base64AttachmentString
});
有没有办法发送 Base64 附件,Mailgun 会将其识别为 PDF?我知道这对于其他邮件程序是可能的,例如 Nodemailer 和 SendGrid。
【问题讨论】:
标签: javascript meteor base64 email-attachments mailgun