개발자 블로그

[Resolved] node mailer - Invalid login: Username and Password not accepted 본문

프로그래밍/Node.js

[Resolved] node mailer - Invalid login: Username and Password not accepted

로이드.Roid 2022. 7. 11. 14:27

Translated by Google Translate.

In my app, I was receiving notifications by gmail using nodemailer for the part that needs monitoring. In the past, it was working fine without any problems, but at some point the mail was not being sent.
So I looked up the error log and found the following log. (It may be slightly different from the original text by deleting or modifying sensitive information.)

 Send mail error:  { Error: Invalid login: Username and Password not accepted. Learn more at
  https://support.google.com/mail/?p=BadCredentials - gsmtp
     at SMTPConnection._formatError (myprojects/node_modules/nodemailer/lib/smtp-connection/index.js:774:19)
     at SMTPConnection._actionAUTHComplete (myprojects/node_modules/nodemailer/lib/smtp-connection/index.js:1513:34)
     at SMTPConnection._responseActions.push.str (myprojects/node_modules/nodemailer/lib/smtp-connection/index.js:540:26)
     at SMTPConnection._processResponse (myprojects/node_modules/nodemailer/lib/smtp-connection/index.js:932:20)
     at SMTPConnection._onData (myprojects/node_modules/nodemailer/lib/smtp-connection/index.js:739:14)
     at TLSSocket.SMTPConnection._onSocketData.chunk (myprojects/node_modules/nodemailer/lib/smtp-connection/index.js:189:44)
     at emitOne (events.js:116:13)
     at TLSSocket.emit (events.js:211:7)
     at addChunk (_stream_readable.js:263:12)
     at readableAddChunk (_stream_readable.js:250:11)
   code: 'EAUTH',
   response: 'Username and Password not accepted. Learn more at https://support.google.com/mail/?p=BadCredentials     - gsmtp',
   responseCode: 535,
   command: 'AUTH PLAIN' }

 

The URL written in the log links to the page below.
https://support.google.com/mail/?p=BadCredentials

 

다른 이메일 플랫폼을 통해 Gmail 확인하기 - Gmail 고객센터

도움이 되었나요? 어떻게 하면 개선할 수 있을까요? 예아니요

support.google.com

This page isn't really helpful. To put it simply, you have probably received an email from Google in the past. I also got the email and just ignored it.. :(

So Google actually already notified me... I just didn't do anything...

 

Well, what's important to us is how to solve it...

Fortunately, you can continue to use nodemailer using gmail if you set up a little.

  1. 2-Factor Authentication
  2. Create App Password

You only need to do these two things.
These settings can be changed from the link below.
https://myaccount.google.com/security

 

Google 계정

보안 계정을 안전하게 보호하기 위해 보안 설정을 검토 및 조정하고 권장사항을 받아보려면 계정에 로그인하세요.

myaccount.google.com


And if you need help with this, please refer to the link below.
https://support.google.com/accounts/answer/185833

 

앱 비밀번호로 로그인 - Google 계정 고객센터

도움이 되었나요? 어떻게 하면 개선할 수 있을까요? 예아니요

support.google.com

 

If you have created an app password, you can change the password of the gmail account to the app password in the existing node.js code. And don't forget to restart the service!

Comments