我有一个动态电子邮件模板,用于向用户发送唯一令牌链接以重置其密码。我将链接分配给我的请求对象中我的个性化的 dynamic_template_data 部分中名为“链接”的字段。当我收到电子邮件时,我的锚标记没有 href 属性。
这是我的请求对象:
{
method: "POST",
url: "/v3/mail/send",
headers: {
"content-type": "application/json"
},
body: {
personalizations: [
{
to: [{ email: email, name: name }],
dynamic_template_data: {
link: link
}
}
],
// some other content
// ...
template_id: Constants.EMAIL.RESET_PASSWORD
},
json: true
}
还有我的 sendgrid 动态模板中的 html:
<div>Use the following link to reset your password: <a href="{{link}}">{{link}}</a></div>
当我收到电子邮件时,链接的文本已正确填充我的动态内容,但该元素没有 href 属性,因此它呈现为纯文本且不可点击:
特别奇怪的是,当我在 SendGrid 的设计编辑器上预览我的动态模板时,href 字段正确地填充了我传入的测试数据。