[英]Dynamic sendgrid templates being sent as plain text
我正在通过sendgrid发送电子邮件,但是当我收到电子邮件时,电子邮件是纯文本格式,我想以html格式发送。 变量 data 是我传递给 sgMail.send 的数据。
module.exports = {
data: {
to: '',
from: '',
subject: '',
text: '',
templateId: '',
dynamic_template_data: {
value_precip: undefined,
value_humidity: undefined,
value_windSpeed: undefined,
value_condition: undefined,
value_activiti: undefined
}
},
set: function(to, from, subject, text, templateId, params) {
this.data.to = to
this.data.from = from
this.data.subject = subject
this.data.text = text
this.data.templateId = templateId,
this.data.dynamic_template_data.value_precipitation = params.value_precipitation
this.data.dynamic_template_data.value_humidity = params.value_humidity
this.data.dynamic_template_data.value_windSpeed = params.value_windy
this.data.dynamic_template_data.value_condition = params.value_condition
this.data.dynamic_template_data.value_activiti = params.value_activiti
},
send: function() {
try {
sgMail.send(this.data)
} catch (error) {
console.log(error)
}
}
}
我不知道是什么导致了这个问题,如果有人能帮助我,我将不胜感激!
看起来 SendGrid 使用html
属性来决定内容类型是否应该是 html ,即使它们忽略了内容。 因此,只需在有效负载中包含该属性。 看起来很奇怪,但它对我有用。
PS:我没有用 JavaScript 尝试过,我用的是 Python。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.