33 lines
815 B
JavaScript
33 lines
815 B
JavaScript
const app = require('../app');
|
|
const nodemailer = require('nodemailer');
|
|
|
|
if (process.env.NODE_ENV !== 'production' || process.env.NODE_ENV !== 'testing') {
|
|
require('dotenv').config();
|
|
}
|
|
|
|
module.exports = {
|
|
send: function (recipient, subject, message) {
|
|
send(recipient, subject, message);
|
|
}
|
|
};
|
|
|
|
|
|
var send = function (recipient, subject, message) {
|
|
transporter.sendMail({
|
|
to: recipient, // list of receivers
|
|
subject: subject, // Subject line
|
|
html: message, // html body
|
|
});
|
|
}
|
|
|
|
let transporter = nodemailer.createTransport({
|
|
host: process.env.MAIL_HOST,
|
|
port: process.env.MAIL_PORT,
|
|
secure: process.env.MAIL_SECURE,
|
|
auth: {
|
|
user: process.env.MAIL_USER,
|
|
pass: process.env.MAIL_PASS,
|
|
},
|
|
}, {
|
|
from: process.env.MAIL_FROM
|
|
}); |