gpt4 book ai didi

javascript - 使用编码为 utf8 的 readFileSync 在 jade 电子邮件模板中呈现 HTML

转载 作者:搜寻专家 更新时间:2023-10-31 23:36:02 25 4
gpt4 key购买 nike

我正在尝试发送一个 jade 电子邮件模板,但它目前将所有内容呈现为字符串而不是实际电子邮件中的 HTML。我尝试为 fs.readFileSync 寻找其他编码类型,但我不确定这是否是我应该改变的。

在这里调用模板:

var emailTemplate = jade.compile(fs.readFileSync('./views/email/new_user.jade', 'utf8'));
var html = emailTemplate({
confirmCode: 233,
name: params.name,
siteName: config.siteName
siteLogo: config.siteLogo
});

模板:

div(style='width: 300px; margin: 0 auto')
div(style='text-align: center')
img(src='#{siteLogo}')
| Hi #{name},
p
| Welcome to #{siteName}! You can now vote on submissions and leave comments.
| In order for your submissions to be public, please confirm your account by
| clicking the confirmation link below
div(style='background-color: #fafafa; border: 1px solid #ddd; border-right: none; border-left: none; display: block; font-weight: bold; line-height: 35px; height: 35px; text-align: center; width: 100%;')
a(href='http://localhost/users/confirm/') Confirm your account

输出(在我的电子邮件中):

<div style="width: 300px; margin: 0 auto"><div style="text-align: center"><img src="http://localhost/site_logo.png"/></div>Hi USER,<p>Welcome to SITENAME! You can now vote on submissions and leave comments. In order for your submissions to be public, please confirm your account by clicking the confirmation link below</p><div style="background-color: #fafafa; border: 1px solid #ddd; border-right: none; border-left: none; display: block; font-weight: bold; line-height: 35px; height: 35px; text-align: center; width: 100%;"><a href="http://localhost/users/confirm/">Confirm your account</a></div></div>

最佳答案

我认为您遇到此问题是因为您电子邮件的Content-Type 不是text/html。尝试这样做。

关于javascript - 使用编码为 utf8 的 readFileSync 在 jade 电子邮件模板中呈现 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15059852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com