【问题标题】:Can I send programatically generated text as a Mailgun attachment using Javascript?我可以使用 Javascript 将程序生成的文本作为 Mailgun 附件发送吗?
【发布时间】:2016-05-31 02:54:44
【问题描述】:

Mailgun documentation 中的示例显示了如何发送由文件名指定的附件。是否可以发送动态生成的字符串?

类似于以下内容:

var form = new FormData();
form.append("from", "me@me.com");
form.append("to", "you@you.com");
form.append("subject", "Email Subject");
form.append("text", "Email body");
form.append("attachment", "Attachment text content", "attachment.txt");

//POST form…

使用此代码可忽略附件。

【问题讨论】:

    标签: javascript attachment mailgun


    【解决方案1】:

    我可以使用 blob 来做到这一点:

    var file = new Blob(["Attachment text content"], {type: "text/plain"});
    form.append("attachment", file, "attachment.txt");
    

    【讨论】:

      猜你喜欢
      • 2021-05-27
      • 2013-04-01
      • 2019-06-13
      • 1970-01-01
      • 1970-01-01
      • 2021-09-10
      • 1970-01-01
      • 2016-09-22
      • 1970-01-01
      相关资源
      最近更新 更多