2020-10-20 19:25:00 +00:00
|
|
|
const nodemailer = require('nodemailer');
|
|
|
|
const config = require('../config/email');
|
|
|
|
|
|
|
|
module.exports = sendEmail;
|
|
|
|
|
|
|
|
async function sendEmail({ to, subject, html, from = config.emailFrom }) {
|
|
|
|
if (config.sendMails) {
|
|
|
|
const transporter = nodemailer.createTransport(config.smtpOptions);
|
|
|
|
await transporter.sendMail({ from, to, subject, html });
|
|
|
|
} else {
|
|
|
|
console.log({
|
2020-11-20 10:02:30 +00:00
|
|
|
to,
|
|
|
|
subject,
|
|
|
|
html,
|
|
|
|
from,
|
2020-10-20 19:25:00 +00:00
|
|
|
});
|
|
|
|
}
|
2020-11-20 10:02:30 +00:00
|
|
|
}
|