Nodemailer-express-handlebars is a useful plugin for Nodemailer that allows you to use Handlebars templates in your HTML emails | Link
The documentation on that page does not provide a full usage example and is really short on details. I then found this article which was incredibly helpful! | Link
...
var hbs = require('nodemailer-express-handlebars');
var options = {
viewEngine : {
extname: '.hbs', // handlebars extension
layoutsDir: 'views/email/', // location of handlebars templates
defaultLayout: 'template', // name of main template
partialsDir: 'views/email/', // location of your subtemplates aka. header, footer etc
},
viewPath: 'views/email',
extName: '.hbs'
};
...
mailer.use('compile', hbs(options));
mailer.sendMail({
from: 'test@test.com',
to: req.body.to,
subject: req.body.subject,
template: 'template',
context: {
firstName: req.body.firstName,
lastName: req.body.lastName,
...
}
}, function(error, response)...)