Skip to content

Instantly share code, notes, and snippets.

@cristofersousa
Created November 3, 2019 03:06
Show Gist options
  • Save cristofersousa/f24eca1a6a537b997317fb4568b96b97 to your computer and use it in GitHub Desktop.
Save cristofersousa/f24eca1a6a537b997317fb4568b96b97 to your computer and use it in GitHub Desktop.
Added mailer with handlebars and nodemailer
const path = require('path');
const nodemailer = require('nodemailer');
const hbs = require('nodemailer-express-handlebars');
const {host, port, user, pass} = require('../config/mail.json');
const transport = nodemailer.createTransport({
host,
port,
auth: { user, pass },
});
const handlebarOptions = {
viewEngine: {
extName: '.html',
partialsDir: path.resolve('./src/resources/mail/'),
layoutsDir: path.resolve('./src/resources/mail/'),
defaultLayout: 'email.html',
},
viewPath: path.resolve('./src/resources/mail/'),
extName: '.html'
};
transport.use('compile', hbs(handlebarOptions));
module.exports = transport;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment