[英]Rendering HTML in jade email templates with readFileSync encoded as utf8
我正在嘗試發送玉石電子郵件模板,但它目前在實際電子郵件中將所有內容呈現為字符串而不是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
。 試着這樣做。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.