我正在尝试使用把手,我完全按照教程说的做了,我的电子邮件似乎根本没有格式化把手。我究竟做错了什么。我在mailchimp发送默认值也是车把。我正在使用JSon中提供的教程示例,只是将代码转换为javascript,但它似乎并没有起作用。
var mandrill = require('mandrill-api/mandrill');
var mandrill_client = new mandrill.Mandrill(MYAPIKEY);
var moment = require('moment-timezone');
var message = {
"subject": '',
"from_email": "myemail",
"from_name": "info",
"to": [{
"email": 'myemail',
"name": "Recipient Name",
"type": "to"
}],
"headers": {
"Reply-To": "message.reply@example.com"
},
"auto_text": true,
"inline_css": true,
"merge": true,
"merge_language": "handlebars",
"global_merge_vars": [
{
"name": "companyName",
"content": "Nesting Doll Emporium"
},
{
"name": "subject",
"content": "Thank you for your order."
}
],
"merge_vars": [
{
"rcpt": "myemail",
"vars": [
{
"name": "ordNumber",
"content": "478366238"
},
{
"name": "products",
"content": [
{
"img": "http://kbcdn.mandrill.com/nesting-penguin.png",
"qty": 2,
"sku": "PENG001",
"name": "Penguin",
"description": "Solid wood, hand-painted penguin nesting doll with 5 different sizes included. Limited Edition.",
"price": "12.99",
"ordPrice": "25.98"
},
{
"img": "http://kbcdn.mandrill.com/nesting-bear.png",
"qty": 3,
"sku": "BBEAR001",
"name": "Brown bear",
"description": "Solid wood, hand-painted brown bear nesting doll. Coordinates with our entire Bear collection. Includes 6 nested sizes.",
"price": "12.99",
"ordPrice": "38.97"
},
{
"img": "http://kbcdn.mandrill.com/nesting-tiger.png",
"qty": 1,
"sku": "TIGER030",
"name": "Tiger",
"description": "Orange striped tiger from our jungle collection.",
"price": "37.99",
"ordPrice": "37.99"
}
]
},
{
"name": "subtotal",
"content": "102.94"
},
{
"name": "shipping",
"content": "4.95"
},
{
"name": "ordTotal",
"content": "107.89"
},
{
"name": "customerName",
"content": [
{
"firstName": "Monty",
"lastName": "Python"
}
]
},
{
"name": "coupon",
"content": [
{
"code": "THANKS",
"description": "15% off"
}
]
},
{
"name": "billingAddress",
"content": [
{
"streetNum": "1234",
"address1": "BoulevArd Lane",
"city": "ATLANTA",
"state": "ga",
"zip": 30030
}
]
},
{
"name": "shippingAddress",
"content": [
{
"streetNum": 5678,
"address1": "BoulevArd Lane",
"city": "atlanta",
"state": "ga",
"zip": 30328
}
]
},
{
"name": "member",
"content": true
},
]
}],
};
var async = false;
var ip_pool = "Main Pool";
now = new Date();
minute = "" + now.getMinutes(); if (minute.length == 1) { minute = "0" + minute; }
second = "" + now.getSeconds(); if (second.length == 1) { second = "0" + second; }
var send_at = moment().format('YYYY-MM-DD HH:'+minute+':'+second);
var template_content = [{
"name": 'handle_bar_test',
"content": "example content"
}];
const payload ={
'template_name':'handle_bar_test',
'template_content': [],
'message':message,
'async':async,
'ip_pool':ip_pool,
'send_at':send_at
}
mandrill_client.messages.sendTemplate(payload, function(result) {
console.log(result);
},
function(e) {
console.log('A mandrill error occurred: ' + e.name + ' - ' + e.message);
});