Sunday, 10 February 2019

Nodemailer, Heroku, Gmail, invalid login - works locally

I have been having this issue for the past couple of weeks, it works every time locally, however once I deploy it to my heroku server, it will give me an invalid login error. I have gone into the account and givin access to less secure apps. And the credentials are correct, and it works on localhost every time. Is there something I am missing?

quickSendMail: function(routeBody, callback) {
//configuring the nodemailer for email notifications
  var smtpConfig = {
          host: 'smtp.gmail.com',
          port: 465,
          secure: true, // use SSL
          auth: {
              user: 'mysmtpemail123',
              pass: '******'
            }
        };

  var mailOptions = {
          from: 'SageStorm Site <mysmtpemail123@gmail.com>',
          to: ['my email'],
          subject: routeBody.subject,
          html: 'my message'
        };

  var transporter = nodemailer.createTransport(smtpConfig);

  transporter.verify(function(error, success) {
        if (error) {
                console.log(error);
        } else {
                console.log('server is ready to send emails');
          }
        })
  transporter.sendMail(mailOptions, function(error, info) {
        if (error) {
              console.log(error);
              return callback(err, null);
        } else {
              console.log('Message sent: ' + info.response);
              return callback(null, info);
          }
        })
    }



from Nodemailer, Heroku, Gmail, invalid login - works locally

No comments:

Post a Comment