我的代码定义为
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");
}
});
});
邮件已成功发送,收件人收到邮件但附件丢失。我如何以数据的形式发送附件?
答案 0 :(得分: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>'
答案 1 :(得分:0)
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
是包含图片网址的参数键。