const libs = `${process.cwd()}/libs`; const log = require(`${libs}/log`)(module); const config = require(`${libs}/config`); const nodemailer = require('nodemailer'); const htmlToText = require('nodemailer-html-to-text').htmlToText; let transporter = nodemailer.createTransport({ host: config.email.host, port: config.email.port, secure: config.email.secure, ignoreTLS: config.email.ignoreTLS }); transporter.use('compile', htmlToText()); // verify connection configuration transporter.verify(function(error, success) { if (error) { log.error(error); } else { log.info('Email server is ready to take our messages'); } }); const mailOptions = { from: config.email.from }; module.exports = function send(options, cb) { let opt = Object.assign({}, mailOptions, options); transporter.sendMail(opt, (err, info) => { if(err) { return cb(err); } cb(null, info); }); };