I am going to send 5 digits to user’s email address. But it is not being sent.
Here is codebase below.
const mailOptions = {
from: 'example@gmail.com',
to: email,
subject: 'Password Reset Token',
text: `Your password reset token is: ${token}`
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log(error);
res.status(500).json({ message: 'Error sending email' });
} else {
console.log('Email sent: ' + info.response);
res.json({ message: 'Token sent to email!' });
}
});
Please let me know what I should fix.
I couldn’t see any emails were sent. Please let me know the issues. Thanks.
>Solution :
You have to use google app password to send an email by using the gmail.
https://support.google.com/accounts/answer/185833?hl=en
I think you used normal password for the your mailer.