【发布时间】:2021-03-11 05:52:40
【问题描述】:
我有一个 Postmark 电子邮件模板,其中动态变量包含 html。但是,它将 html 处理为纯文本。
更具体地说,我有下面的代码。变量body 被发送到电子邮件模板,但<br><br> 显示为文本,而不是转到下一行。
在控制器中:
const body = "Hi...<br><br> Welcome to our a new episode.";
client.sendEmailWithTemplate(
{
TemplateAlias: process.env.POSTMARK_TEMPLATE,
TemplateModel: {
body: body
},
From: from,
To: email,
});
在邮戳模板中:
<tr>
<td>
1. The following includes text with a br break: {{body}}
</td>
</tr>
<tr>
<td>
2. This line includes a br break directly in the template: How are you? <br> Anything new?
</td>
</tr>
这会产生一封电子邮件,其中 br 中断在位置 2 上起作用,但在位置 1 上不起作用。在位置 1 上,<br> <br> 显示为文本:“<br> <br>”。
我做错了什么?
【问题讨论】:
标签: node.js email templates postmark