这是我的代码:
export class EmailGateway {
constructor(mandrill, person) {
this.person = person;
this.to = [{
"email": this.person.email,
"name": `${this.person.first} ${this.person.last}`,
"type": "to"
}];
this.mandrill = mandrill;
}
sendTemplateMessage(templateName, mergeVars) {
return new Bluebird((resolve, reject) => {
this.mandrill.messages.sendTemplate({
"template_name": templateName,
"template_content": [],
"async": true,
"message": {
"to": this.to,
"global_merge_vars": mergeVars,
"merge": true
}
}, resolve, reject);
});
}
}
let person = config.person.person;
let e = new EmailGateway(client, person);
let mergeVars = [
{
"name": "first_name",
"content": person.first
},
{
"name": "cs_date",
"content": config.callsheet.related('day').get('date')
},
{
"name": "calltime",
"content": person.callTime
},
{
"name": "parking_location",
"content": config.callsheet.related('misc').related('location').fullLocation()
},
{
"name": "notes",
"content": ""
},
{
"name": "dept_notes",
"content": config.note
},
{
"name": "cs_confirmlink",
"content": "http://www.setheroapp.com/"
},
{
"name": "cs_link",
"content": "http://www.setheroapp.com/"
}
];
e.sendTemplateMessage('Callsheet Email', mergeVars).then(res => {
console.log(res);
return next(null, res);
}).catch(e => {
console.log(e);
});
每次发送带有上述代码的电子邮件时,我都会收到电子邮件,但没有一个合并变量被替换。
答案 0 :(得分:0)
将Mandrill中的合并变量从MailChimp标签更改为Handlebar标签,现在一切正常