// script.js
module.exports = {
mail: pool.query('SELECT email FROM clients WHERE email_status IS NULL')
}
// nodemailer.js
var mail = require('./script');
let mailOptions = {
from: 'test@gmail.com',
to: mail.mail,
subjects: 'Testing',
text: 'It works!'
}
const mailer = message => {
//nodemailer.js
transporter.sendMail(message, function(err, data) {
if (err) {
console.log('Error!!!', err);
} else {
console.log('Cool!!!');
}
})
}
module.exports = mailer;
//script.js
const mailer = require("./nodemailer");
const message = {
from: 'Hello! <test@gmail.com>',
to: req.body.email,
}
mailer(message);