我正在发送Mandrill API的模板电子邮件,如下所示:
{
"key":"xxxyyyzzz",
"template_name":"coupon-purchased",
"template_content":[
],
"message":{
"to":[{"email":"xxx@yyy.com"}]
},
"merge":true,
"global_merge_vars":[
{
"name":"FNAME",
"content":"Your name"
},
{
"name":"FGYMNAME",
"content":"Your gym"
}
],
"merge_vars":[
{
"rcpt": "xxx@yyy.com",
"vars":[
{
"name":"FNAME",
"content":"Your name"
},
{
"name":"FGYMNAME",
"content":"Your gym"
}
]
}]
}
作为此网址的POST消息:https://mandrillapp.com/api/1.0/messages/send-template.json
我尝试过一些HTML文档,但最后我只是将以下内容用作模板:
*|FNAME|* and *|FGYMNAME|*
但仍然无法正常工作。这些变量不与global_merge_vars中发送的值交换。
此外,我尝试从JSON中删除merge_vars
和merge
属性,但两者都没有。
关于它的任何线索?
谢谢!
答案 0 :(得分:6)
您似乎在merge_vars
中没有merge
,global_merge_vars
和message
参数。它们应嵌套在message
中才能生效。所以它看起来像这样:
{
"key": "xxxyyyzzz",
"template_name": "coupon-purchased",
"template_content": [],
"message": {
"to": [
{
"email": "xxx@yyy.com"
}
],
"merge": true,
"global_merge_vars": [
{
"name": "FNAME",
"content": "Your name"
},
{
"name": "FGYMNAME",
"content": "Your gym"
}
],
"merge_vars": [
{
"rcpt": "xxx@yyy.com",
"vars": [
{
"name": "FNAME",
"content": "Your name"
},
{
"name": "FGYMNAME",
"content": "Your gym"
}
]
}
]
}
}
Mandrill API文档也有JSON示例,您可以将其用于比较。这是message / send-template的JSON链接:https://mandrillapp.com/api/docs/messages.JSON.html#method=send-template