This is my settingController:
var sendSmtpMail = function (req,res) {
var transport = nodemailer.createTransport({
service:\'gmail\',
auth: {
If you have enabled 2-factor authentication on your Google account you can't use your regular password to access Gmail programmatically. You need to generate an app-specific password and use that in place of your actual password.
Steps:
Your script will now look like this:
var transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'YOUR-GMAIL-USERNAME@gmail.com',
pass: 'YOUR-GENERATED-APP-PASSWORD'
}
});
I hope this helps someone.