33

I found this error while i'm trying to send an email from one Gmail account to another. How to solve this error ? Help me on it.

There were an error:

Invalid login: 534-5.7.14 Please log in via 534-5.7.14 your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 a90-v6sm7292588pfg.106 - gsmtp

I have already try Allow less secure apps to be ON but still same error. it working correctly when i run application on local machine but this error on server machine

Please help me

ouflak
  • 2,458
  • 10
  • 44
  • 49
sways
  • 331
  • 1
  • 3
  • 7

7 Answers7

48

You might need to allow access to your Gmail account.

https://accounts.google.com/b/0/DisplayUnlockCaptcha

Edit (after your comment)

// create reusable transporter object using the default SMTP transport

transporter = nodemailer.createTransport({
    host: 'smtp.gmail.com',
    port: 465,
    secure: true, 
    auth: {
        user: 'yourEmail', 
        pass: 'yourPassword' 
    }
});

your 'nodemailer.createTransport' should look something similar.

Shanil Arjuna
  • 1,135
  • 10
  • 18
26

If you use GMAIL service as a transporter,

Step-1: Log in to your gmail account.

Step-2: Enable less secure app access and/or DisplayUnlockCaptcha on your gmail account.

Step-3: Follow a 6-step guide on Sign in with App Passwords

Step-4: Replace your transporter password with the 16-character generated app password you obtain from Step-3 above.

These four easy steps solved my problem.

Laurel
  • 5,965
  • 14
  • 31
  • 57
Pelesi Pelesi
  • 259
  • 3
  • 4
  • it worked thanks! But its not working with the normal gmail. It worked with email@website.com – Biku7 Dec 15 '20 at 08:04
  • 1
    This is much better way. Now i am able to use in aws lambda. – Lohith Feb 14 '21 at 05:44
  • 1
    This worked for Firebase Cloud functions, thank you! – Dustin Spengler Feb 14 '21 at 06:47
  • 1
    This worked for me as well. No matter what I tired prior, google did not like my password while running my app on my live host. My local host was perfectly fine. Not until I followed this process, its now working in both my local and live environments. Many thanks! – klewis May 21 '21 at 18:52
3

Most of the time, this occurs only because of two major issues

  1. I yet to enable the less secure option in google account under security
  2. You should allow the google account to be accessed by the third party application. See https://accounts.google.com/DisplayUnlockCaptcha
bguiz
  • 27,371
  • 47
  • 154
  • 243
Vijay Anand.M
  • 81
  • 1
  • 1
1

I got the same issue as this works fine using postman client on local environment.

But giving the error or aws-linux vpc i configured.

So this can be fixed as:

let nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 587,
ignoreTLS: false,
secure: false,
auth: {
    user: "your mail",
    pass: 'your password'
}
});
module.exports = transporter;

Please make sure you have allow access to your account and less secure apps setting should be turned on.

shubham yadav
  • 172
  • 1
  • 5
1

You just have to open the below link and enable to allow your google account access.

This will allow Google to complete this additional step when signing into a new device or application.

Nilesh Patil
  • 41
  • 1
  • 2
0

the low security methode was temporary and i couldn't use it in production but I found an article that made it easier using OAuth to connect to GMail here with an example code and it works perfect

bessam Sahli
  • 105
  • 7
0

For gmail, you need to allow 2 step authorisation and then set up a 16 digit app password. Use that password with your gmail address, - not your regular password. Should be good to go!