Answer the question
In order to leave comments, you need to log in
What can I do to send an email to specific users?
I need to send an email to those whose mail status is unconfirmed (NULL) from a MySQL database. I use "nodemailer" Tried like this
// 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: '[email protected]',
to: mail.mail,
subjects: 'Testing',
text: 'It works!'
}
Answer the question
In order to leave comments, you need to log in
I decided (when entering mail on the form, a letter is immediately sent to the specified address :) ):
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! <[email protected]>',
to: req.body.email,
}
mailer(message);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question