Rendering HTML in jade email templates with readFileSync encoded as utf8

express, javascript, node.js, pug

Solution

I think you're having this problem because the `Content-Type` of your e-mail is not `text/html`. Try doing so.

Problem

I'm trying to send a jade email template but it's currently rendering everything as a string instead of HTML in the actual email. I tried looking for other encoding types for `fs.readFileSync` but am not sure if that's what I should even be changing. Calling the template here: ``` 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 }); ``` The template: ``` 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 ``` Output (in my email): ``` <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> ```

Original source