Created
November 3, 2019 03:06
-
-
Save cristofersousa/f24eca1a6a537b997317fb4568b96b97 to your computer and use it in GitHub Desktop.
Added mailer with handlebars and nodemailer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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