[英]Parse main.js Mandrill HTML mail sending issue
I have a cloud function on Parse in main.js where I send mail as HTML encoded with Mandrill API. 我在main.js中的Parse上有一个云函数,在其中我将邮件发送为使用Mandrill API编码的HTML。 I call this function through my iOS app posting some parameters and its perfectly ok, sends the email. 我通过我的iOS应用程序调用了此功能,其中发布了一些参数,它的功能还可以,发送电子邮件。 However I want to localize the HTML body depending on the language of user. 但是我想根据用户的语言本地化HTML正文。 Since I checked the iOS in-line HTML options which are very tricky, I'm trying to do it in my sendMail function on main.js: 由于我检查了非常棘手的iOS内联HTML选项,因此我尝试在main.js的sendMail函数中执行此操作:
Parse.Cloud.define("sendMail", function(request, response) {
var Mandrill = require('mandrill');
Mandrill.initialize('APP_ID');
var locale = request.params.locale;
var userName = request.params.user;
var password = request.params.pass;
var HTMLBodyEn = '<p>text</p>';
var HTMLBody = HTMLBodyEn;
if (locale == 'tr') {
HTMLBody = '<p>yazı</p>';
}
Mandrill.sendEmail({
message: {
html: HTMLBody,
subject: request.params.subject,
from_email: request.params.fromEmail,
from_name: request.params.fromName,
to: [
{
email: request.params.toEmail,
name: request.params.toName
}
]
},
async: true
},{
success: function(httpResponse) {
console.log(httpResponse);
response.success("Email sent!");
},
error: function(httpResponse) {
console.error(httpResponse);
response.error("Uh oh, something went wrong");
}
});
});
Well it's simple as that. 嗯,就是这么简单。 If condition you see there causes all the problem... As you can see there I'm receiving a locale key to change the body but it doesn't and Parse returns 141 error code which means after some digging is a time-out exception . 如果您发现那里的情况导致了所有问题,那么…如您所见,我收到一个区域设置键来更改主体,但没有,并且Parse返回141错误代码,这意味着在进行某些挖掘之后是超时异常 。
I can't seem to understand that a simple if statement as that causes a timeout. 我似乎无法理解,简单的if语句会导致超时。
Can anyone help me on this? 谁可以帮我这个事? Encountered anything similar? 遇到过类似的事情吗?
You might be experiencing side effects from a text encoding issue. 您可能会遇到来自文本编码问题的副作用。 The Mandrill SDK on parse doesn't appear to handle the charset you're using. 解析中的Mandrill SDK似乎无法处理您使用的字符集。 Take a look at this post from their forums that offers a workaround for that problem. 在他们的论坛中查看此帖子,该帖子提供了解决该问题的方法。
https://www.parse.com/questions/sometimes-getting-mandrill-you-must-specify-a-key-value-error-when-sending-email https://www.parse.com/questions/sometimes-getting-mandrill-you-must-specify-a-key-value-error-when-sending-email
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.