【问题标题】:Mailgun: Sending image using parse cloud codeMailgun:使用解析云代码发送图像
【发布时间】:2014-08-06 13:13:18
【问题描述】:

我有一个代码定义为

Parse.Cloud.define("mailgunSendMail", function(request, response) {

               var Mailgun = require('mailgun');
               Mailgun.initialize('photoshare.com', 'APPKey');

               Mailgun.sendEmail({
                                 to: "toTestUser@mail.com",
                                 from: "fromTestUser@mail.com",
                                 subject: "Hello from Cloud Code!",
                                 text: "Using Parse and Mailgun is great!",
                                 attachment:"ZXhhbXBsZSBmaWxl"
                                 }, {
                                 success: function(httpResponse) {
                                 console.log(httpResponse);
                                 response.success("Email sent!");
                                 },
                                 error: function(httpResponse) {
                                 console.error(httpResponse);
                                 response.error("Uh oh, something went wrong");
                                 }
                                 });
               });

邮件发送成功,收件人收到邮件,但附件丢失。如何以数据的形式发送附件?

【问题讨论】:

    标签: ios parse-platform mailgun


    【解决方案1】:

    根据解析,此时没有办法在电子邮件中发送附件。 Check this link

    但是,如果您可以像这样在 HTML 代码中包含您的图像文件,如果这符合您的需要。

    html: '<html><body style="text-align:center;"><img border="0" src="http://files.parse.com/6ffa6b80-d0eb-401f-b663-22d4a16df004/bfed9ac4-058c-41fc-a0f1-fb6155572c12-ad77a082-453f-42f7-94ef-40c3f3e885e6.png" alt="Pulpit rock" width="300" height="150"></body></html>'
    

    【讨论】:

    • 如何将请求参数中获取的图片 url 插入到这个 html 字符串中?
    • 你可以这样做 html: ''
    【解决方案2】:

    Subash 的答案是正确的。我刚刚编辑了我的问题:

    Parse.Cloud.define("mailgunSendMail", function(request, response) {
               var Mailgun = require('mailgun');
               Mailgun.initialize('photoshare.com', 'AppKey');
    
               Mailgun.sendEmail({
                                 to: "toTestuser@mail.com",
                                 from: "fromTestUser@mail.com",
                                 subject: "Hello from Cloud Code!",
                                 text: "Using Parse and Mailgun is great!",
                                 html: '<html><body><img src="' + request.params.imageUrlKey + '"></body></html>'                                 }, {
                                 success: function(httpResponse) {
                                 console.log(httpResponse);
                                 response.success("Email sent!");
                                 },
                                 error: function(httpResponse) {
                                 console.error(httpResponse);
                                 response.error("Uh oh, something went wrong");
                                 }
                                 });
               });
    

    其中imageUrlKey 是一个包含图片url的参数键。

    【讨论】:

      猜你喜欢
      • 2016-04-16
      • 2015-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-27
      • 2023-03-06
      • 1970-01-01
      相关资源
      最近更新 更多