sendgrid - 使用 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}}
解决方案
我进行了两次更新以使其正常工作。
addCustomArg
我没有使用 PHP中的库,而是更新为使用addDynamicTemplateDatas
并且还更新了把手以在变量名前后有一个空格:{{ refnum }}
.
它仍然没有在模板编辑器中通过,但它被验证在发送的电子邮件中。
推荐阅读
- rabbitmq - 无状态服务之间的 Service Fabric 发布/订阅消息
- java - 如何从 kotlin 中的辅助构造函数调用“super()”?
- docker - docker global service 和replication 有什么区别,以及如何更改全局服务的数量?
- python - 创建一个在同一文件夹中创建可执行文件管理器的 Python Makefile
- python-3.x - 为什么 Scapy 会重新计算碎片大小?
- reactjs - 如何将数据从状态传输到 mapdispatchtoprops?
- php - CI 默认控制器显示空白页面
- python - 如何在python中从csv文件中提取字符串
- c++ - (C++) 制作一组数字 1-3 的随机序列
- mysql - 使用 MySQL 的数据库表中的版本控制元素