Nuru Salihu Nuru Salihu - 4 months ago 34x
Node.js Question

How to pass express variable to .jade email template file

I mam nodemailer Here and my email template Here.

exports.newRegistration = function(user, req){

var sendPwdReminder = transporter.templateSender(new EmailTemplate(templateDir));

// setup e-mail data with unicode symbols
var formattedUrl = url.format({
protocol: req.protocol,
host: req.get('host')
// use template based sender to send a message
from: '"


I would rework this a slightly. If you call template.render() first you should be able to get the HTML or text of the email, which you can pass on to nodemailer:

var template = new EmailTemplate(templateDir);
template.render({"username": user.username}, function(err, result) {
    var mailOptions = {};
    transporter.sendMail(mailOptions, function(error, info) {
        // Handle error, etc