sendgrid - 通过带有 '&' 的 sendgrid 发送模板电子邮件时发出警告

标签 sendgrid sendgrid-api-v3 sendgrid-templates

我在 sendgrid api v3 的帮助下发送电子邮件,但收到警告/错误:

Content with characters ', " or & may need to be escaped with three brackets {{{ content }}}



在我的 api json 中,我添加了一个包含 & 的链接特点:
{"dynamic_template_data": {"link":"...&..."}}
在我的模板中,我使用了三个括号 {{{ link }}}
一切都按预期工作 - 电子邮件包括。链接已发送 - 但我总是收到警告/错误。

我是否错过了 json 中的某些内容?

最佳答案

我已经查看了他们的 node.js 代码,只要任何内容​​字符串包含 (",',&) ,它就会对您看到的消息进行控制台警告。

if (/['"&]/.test(value)) {
   console.warn(DYNAMIC_TEMPLATE_CHAR_WARNING);
}

见:https://github.com/sendgrid/sendgrid-nodejs/blob/47b6a5cd583cc10544ac19434419bdda5272b107/packages/helpers/classes/mail.js

您可以注意到在下面的 sendgrid 的电子邮件模板上使用 2 和 3 括号的区别:
enter image description here

关于sendgrid - 通过带有 '&' 的 sendgrid 发送模板电子邮件时发出警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57079010/

相关文章:

javascript - Firestore 云功能 - 使用 SendGrid 在Create 上发送电子邮件

node.js - SendGrid NodeJS - Client.request() 不是函数

ruby - 使用最大行长度简洁地序列化 JSON

node.js - Windows 控制台上 nodejs 上的 TypeError : Cannot read property 'isMultiple' of undefined (using sendgrid,)

javascript - Sendgrid 动态模板从 anchor 标记中剥离 HREF

c# - 如何将所有交易模板从一个 SendGrid 帐户迁移到另一个帐户?

c# - 在 SendGrid C# 中将电子邮件作为日历邀请/约会发送

sendgrid - 有没有办法在不同的开发生命周期环境中使用 SendGrid 模板版本控制?

sendgrid-api-v3 - SendGrid - 未在退回事件中返回 custom_args

javascript - 使用 Nodejs 的 SendGrid 模板中的变量替换不起作用