通过模板变量h:X-Mailgun-Variables
传递带引号的文本时遇到问题
我正在使用mailgun-js软件包并像这样发送:
const mailData = {
from: 'Insights <insights@test.net>',
to: mailAddress,
subject: `Insights: ${DAYS_OF_WEEK[date.getDay()]}, ${MONTHS[date.getMonth()]} ${ordinal_suffix_of(date.getDate())} ${date.getFullYear()}`,
template: "template1",
'h:X-Mailgun-Variables': JSON.stringify({test: "this is test content. The apostrophe here - ' breaks."}),
};
但是,将单引号放入电子邮件时,始终将其转换为HTML实体'
,因此上面的文本内容将显示为
this is test content. The apostrophe here - ' breaks.
我有什么办法可以防止这种情况的发生?