- Mailer setup
This commit is contained in:
17
lib/Mailer.js
Normal file
17
lib/Mailer.js
Normal file
@@ -0,0 +1,17 @@
|
||||
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);
|
||||
};
|
||||
Reference in New Issue
Block a user