I am using nodejs with nodemailer for sending emails to users.
I have a list of users like this :-
[
{
name: "John Doe",
email: "john@something.com"
},
{
name: "Jane Doe",
email: "jane@something.com"
}
...and more.
]
How can I send email to all the users in array using nodemailer.
See my code -
users.map(user => {
const mailOptions = {
from: '*****@gmail.com',
to: user.email,
subject: subject, // Any subject
text: message // Any message
}
transporter.sendMail(mailOptions, (err, info) => {
if (err) {
console.log(err)
} else {
console.log(info)
}
})
})
Is this a correct way of doing this ?
Thanks in advance !