首页 > 解决方案 > 使用 Sendgrid Handlebars 调用 JSON 数据

问题描述

我正在使用以下 JSON 创建一个 SendGrid 模板:

    { "personalizations": [ { "to": [ { "email": "to@email.com" } ], "custom_args": { "refnum": "222111", "datetime": "Monday, 4:30" } } ], "from": { "name": "From Person", "email": "marketing@email.com" }, "reply_to": { "name": "reply-to-name", "email": "reply-to@email.com" }, "template_id": "template-id888939333", "tracking_settings": { "click_tracking": { "enable": true, "enable_text": true }, "open_tracking": { "enable": true }, "ganalytics": { "enable": true, "utm_source": "autoeml", "utm_medium": "email", "utm_content": "222111", "utm_campaign": "email" } } }

模板发送良好 - 我无法让车把显示在电子邮件模板中,我已经尝试了以下所有方法:

{{personalizations.custom_args.refnum}}
{{custom_args.refnum}}
{{refnum}}

标签: sendgridsendgrid-templates

解决方案


我进行了两次更新以使其正常工作。

addCustomArg我没有使用 PHP中的库,而是更新为使用addDynamicTemplateDatas并且还更新了把手以在变量名前后有一个空格:{{ refnum }}.

它仍然没有在模板编辑器中通过,但它被验证在发送的电子邮件中。


推荐阅读