18 lines
552 B
JavaScript
18 lines
552 B
JavaScript
const config = require('../config.js');
|
|
const nodemailer = require('nodemailer');
|
|
|
|
const from = `"${config.mail.from.name}" <${config.mail.from.address}>`;
|
|
const transporter = nodemailer.createTransport(config.mail.smtp);
|
|
|
|
module.exports = (email, options, callback) => {
|
|
callback = typeof callback === 'function' ? callback : (error, info) => {
|
|
if (error) {
|
|
return console.log(error);
|
|
}
|
|
|
|
console.log('Message %s sent: %s', info.messageId, info.response);
|
|
};
|
|
|
|
transporter.sendMail({ to: email, from, ...options }, callback);
|
|
};
|