Mandrill车把的例子

时间:2015-08-12 22:56:05

标签: javascript json mandrill

我的html内容中的变量似乎被剥离,因此电子邮件中没有显示动态内容。模板语言设置为代码中的把手和全局。

文档似乎没有提供任何其他详细信息或示例。没有错误消息。

var subject = "A really great subject";
            var htmlContent = "<h1>Hi, {{user}}</h1><p>{{productName}}?</p><br/><a href='{{unsub redirect_merge_var}}'>Unsubscribe</a>"

var mailJSON ={
                    "key": "myKey",
                    "merge_language": "handlebars",
                    "merge": true,
                    "global_merge_vars": [
                        {
                            "name": "productName",
                            "content": "Mandrill_User1"
                        },
                        {
                            "name": "user",
                            "content": "cool guy"
                        }
                    ],
                    "message": {
                        "html": htmlContent,
                        "subject": subject,
                        "from_email": "stuff@xxxxxxxxxx.com",
                        "from_name": "stuff-app",
                        "to": [
                            {
                                "email": ""+person.email,
                                "name": ""+person.name,
                                "type": "to"
                            }
                        ],
                        "important": false,
                        "track_opens": null,
                        "track_clicks": null,
                        "auto_text": null,
                        "auto_html": null,
                        "inline_css": null,
                        "url_strip_qs": null,
                        "preserve_recipients": null,
                        "view_content_link": null,
                        "tracking_domain": null,
                        "signing_domain": null,
                        "return_path_domain": null
                    },
                    "async": false,
                    "ip_pool": "Main Pool"
                }

1 个答案:

答案 0 :(得分:2)

移动这个:

 "merge_language": "handlebars",
 "merge": true,
 "global_merge_vars": […],

进入message结构。 (Official API documentation

如果您不需要,也可以删除NULL值。