mc:edit在使用Mandrill Javascript API的Mailchimp模板中不起作用 [英] mc:edit do not work in Mailchimp template with Mandrill Javascript API
问题描述
我正在尝试通过带有Mailchimp模板的Mandrill API发送电子邮件.我正在使用Parse.com在云代码中进行此操作,请参见 https://www.parse. com/docs/cloud_modules_guide#mandrill .电子邮件发送正常,但是,mc:edit字段永远不会更新.这是模板中唯一的内容:
I'm trying to send emails through the Mandrill API with Mailchimp templates. I am doing this in the cloud code with Parse.com, see here https://www.parse.com/docs/cloud_modules_guide#mandrill. The emails are sent just fine, however, the mc:edit fields are never updated. This is the only content in the template now:
<span mc:edit="ship_id">ship_id</span>
这就是我用Java语言编写的电话,希望有人看到我的错误.如果有任何区别,我将在Parse.com云代码中运行此代码.非常感谢!
This is what my call in Javascript looks like, hope somebody sees my mistake. I'm running this in Parse.com cloud code if that makes any difference. Thanks a lot!
var Mandrill = require('mandrill');
Mandrill.initialize('api-key');
Mandrill.sendTemplate({
template_name: "Drip campaign",
template_content: [{
name: "ship_id",
content:"Test Test"
}],
message: {
text: "Hi",
subject: "You have new mail",
from_email: "info@example.com",
from_name: "Thomas",
to: [
{
email: "answer@example.com",
name: "Fred"
}
],
"headers": {
"Reply-To": "answer@example.com"
},
"important": false,
"track_opens": true,
"track_clicks": true,
},
async: true
},{
success: function(httpResponse) {
response.success("Email sent!");
},
error: function(httpResponse) {
console.error(httpResponse);
response.error("Uh oh, something went wrong");
}
});
}
推荐答案
据我所知,您想在动态编辑邮件内容的同时发送电子邮件.如前所述,您可以通过Mandrill API进行操作.我建议您使用链接中可下载的js文件;
As far as I understand from your question that you want to send e-mail at the same time you want to dynamically edit the mail content. As you have already used, you can do it via the Mandrill API. I suggest you to use the js files which are downloadable in the link;
https://github.com/jlainog/parse-mandrill-sendTemplate
从github帐户中的js文件中,您可以使用标签mc:edit动态编辑邮件内容(必须在模板中).
From the js file in the github account, you can dynamically edit the mail content(must be in your template) via using the tag mc:edit.
对于我来说,代码的工作副本在下面;
For my case working copy of code is below;
Parse.Cloud.define("sendMail", function(request, response) {
var Mandrill = require('cloud/mandrillSend.js');
var sentTo = //Mail address to sent
var subject = //Mail Subject
var fromEmail = //From email
var fromName = //From Name
var sentToName = //Parameters from request
var fullName = //Full Name
Mandrill.initialize('YOUR MANDRILL API KEY');
Mandrill.sendTemplate({
template_name: "MANDRIL TEMPLATE",
template_content: [
{
name: "nameHeader",
content: sentToName,
},
{
name: "mail",
content: sentTo,
},
],
"key": "YOUR MANDRILL API KEY",
message: {
subject: subject,
from_email: fromEmail,
from_name: fromName,
to: [{
email: sentTo,
name: fullName
}],
important: true
},
async: false
}, {
success: function (httpResponse) {
console.log(httpResponse);
response.success("Email sent!");
},
error: function (httpResponse) {
console.error(httpResponse);
response.error("Uh oh, something went wrong");
}
});
});
例如,在Mandrdil模板中有一个跨距为id的
For example, in Mandrdil Template there is a span with the id;
<span mc:edit="mail"> test@gmail.com</span>
希望这会有所帮助. 问候.
Hope this helps. Regards.
这篇关于mc:edit在使用Mandrill Javascript API的Mailchimp模板中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!