I am using nodemail npm package.
I configured the options like this:
function feedback(req, res, next){
console.log('feed back given....', req.body);
smtpTrans = nodemailer.createTransport('SMTP', {
service: 'Gmail',
host: 'smtp.gmail.com',
port: 587,
secure: false,
ignoreTLS: false,
tls: { rejectUnauthorized: true },
debug: false,
auth: {
user: "xxxxxx@gmail.com",
pass: "xxxxxx"
}
});
//Mail options
mailOpts = {
from: from: req.body.email,
to: 'xxxxxx@gmail.com',
subject: 'EMAIL FROM Rsc-student: ' + req.body.subject,
text: req.body.message
};
smtpTrans.sendMail(mailOpts, function (error, response) {
//Email not sent
if (error) {
res.send(error);
console.log('error sending mail');
}
else {
res.send(response);
console.log('success sending mail');
}
});
}
If I am not wrong, I configured correctly but still unable to send mail. Its printing the error case