Nodemailer: { Error: Invalid login: 535 5.7.3 Authentication unsuccessful}

Created on 1 Nov 2018  路  13Comments  路  Source: nodemailer/nodemailer

Hi,

I am trying to send email through nodejs using nodemailer module, I am using the following piece of code to send email:

var transporter = nodemailer.createTransport({
    host: 'smtp.mycompany.com',
    port: 587,
    secure: false,
    auth: {
        user: "[email protected]",
        pass: "mypassword"
    }
});

var mailOptions = {
from: '[email protected]',
to: '[email protected]',
subject: "Test",
text: '',
html: ''
};
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log("info > ",info);

    });

the same code was working perfectly in last 7 to 8 months but recently I started receiving following error:
{ Error: Invalid login: 535 5.7.3 Authentication unsuccessful
at SMTPConnection._formatError (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:606:19)
at SMTPConnection._actionAUTHComplete (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:1335:34)
at SMTPConnection._responseActions.push.str (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:1293:18)
at SMTPConnection._processResponse (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:762:20)
at SMTPConnection._onData (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:558:14)
at TLSSocket._socket.on.chunk (/var/task/node_modules/nodemailer/lib/smtp-connection/index.js:709:51)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at TLSSocket.Readable.push (_stream_readable.js:134:10)
code: 'EAUTH',
response: '535 5.7.3 Authentication unsuccessful',
responseCode: 535,
command: 'AUTH LOGIN' }

I have checked that credentials are correct and we have not made any changes. It was working since last 8 months perfectly.

Most helpful comment

Check your credentials, some hosts require additional validation before you can use SMTP

Is it possible that they do not require these on localhost and only on the domain? Because on localhost it works fine and I get this error thrown on my server.

All 13 comments

@Meenakshi14 , I have also faced the same issue. I have contacted my MS team and confirmed that for sending email via our company smtp mail server they are not expecting any credentials. (means say our company email is [email protected], to send email via using this no need add "auth" object.)
After removing the auth object it worked perfectly fine for me.!

Thanks and Regards,
Kishore Kumar. K

I have also faced the same issue. I am from china. I used tencent smtp.qq.com. I applied the auth code and sent mail successfully. But ... it failed last two days. why?

@puXiaoyi, What is the error you are facing. Please enable debug and post the log.

Check your credentials, some hosts require additional validation before you can use SMTP

I have also faced the same issue. I am from china. I used tencent smtp.qq.com. I applied the auth code and sent mail successfully. But ... it failed last two days. why?

maybe you need take a authorization code from QQ mail

Unhandled error for request POST /api/rusers: Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials l19sm4586061wrg.29 - gsmtp

I have also faced the same issue, so anyone has find the solution?

if you're using google then generate app password, and replace current account password in .env to generated app password

Check your credentials, some hosts require additional validation before you can use SMTP

Is it possible that they do not require these on localhost and only on the domain? Because on localhost it works fine and I get this error thrown on my server.

Check your credentials, some hosts require additional validation before you can use SMTP

Is it possible that they do not require these on localhost and only on the domain? Because on localhost it works fine and I get this error thrown on my server.

For some reason i get the same problem and cannot find any solution to this. Anyone?

I had this issue and the problem was the 2AF activated at the account.

I had the same problem and the issue was this:

I was using credentials provided by my hosting provider. The default setting was that the credentials were secured with GEO security, meaning the credentials wouldn't work outside my country. I was deploying on Heroku whose servers are abroad. That's why I could send emails from localhost but not from deployed app.

After I disabled the GEO security everything worked as it should.

Tuve el mismo problema y el problema fue este:

Estaba usando las credenciales proporcionadas por mi proveedor de alojamiento. La configuraci贸n predeterminada era que las credenciales estaban protegidas con seguridad GEO, lo que significa que las credenciales no funcionar铆an fuera de mi pa铆s. Estaba implementando en Heroku cuyos servidores est谩n en el extranjero. Es por eso que podr铆a enviar correos electr贸nicos desde localhost pero no desde la aplicaci贸n implementada.

Despu茅s de que desactiv茅 la seguridad de GEO, todo funcion贸 como deber铆a.

MAN como desactivaste la seguridad Geo de heroku ? tengo ese problema estoy seguro

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nedudi picture Nedudi  路  5Comments

JYC-99 picture JYC-99  路  6Comments

thalesfsp picture thalesfsp  路  3Comments

molerat619 picture molerat619  路  3Comments

jeevankk picture jeevankk  路  6Comments