To send the mails successfully follow the steps given below:
- Admin must use a gmail account which had its permissions changed by using the link provided here. Give the require access.
- Now use the same ID in med_mail to fill in the credentials (user and password).
const transporter = nodemailer.createTransport({
service: "gmail",
auth: {
user: "<admin@gmail.com>",
pass: "<password>"
}
});
- Next one must set the mail settings accordingly.
const mailOptions = {
from: '"TITLE " admin@gmail.com', // sender address
to: "sender1@gmail.com , ", // list of receivers
subject: "SUBJECT", // Subject line
text: "ALERT", // plain text body
html: "<b>MESSAGE</b>", // html body
};
- Save the code and you are good to go.