[英]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.