3

翡翠の電子メールテンプレートを送信しようとしていますが、現在、実際の電子メールでは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>
4

1 に答える 1

6

Content-Typeあなたの電子メールはそうではないので、あなたはこの問題を抱えていると思いますtext/html。そうしてみてください。

于 2013-02-25T05:13:48.850 に答える