Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

smtplib.SMTPAuthenticationError: (534, b'5.7.9 Application-specific password required

smtplib.SMTPAuthenticationError: (534, b'5.7.9 Application-specific password required. Learn more at\n5.7.9 https://support.google.com/mail/?p=InvalidSecondFactor h22sm15927247pfv.25 - gsmtp')

Environment variable are set but does not work (even though it's the exact value).

  • I have set the app password in google account, captcha is disabled
  • I have set the env variables in .bashrc file export EMAIL_USER='[email protected]'
  • Comparison btw the os.environ.get('EMAIL_USER') and the mail value string is True

I am trying to import this in config file, when I use harcoded values it worked fine, but use I use os.environ.get('EMAIL_USER'), it stops working and throws this error.


1 Answers

An app password is a 16-digit passcode that gives a less secure app or device permission to access your Google Account. App passwords can only be used with accounts that have 2-Step Verification turned on.

https://support.google.com/accounts/answer/185833?hl=en

Use apps password such as EMAIL_USER="example.com" EMAIL_PASSWORD="twtsxiraaxpcuhuyp". If you do not have a gmail apps password, create a new app with using generate password. Check your apps and passwords https://myaccount.google.com/apppasswords. Good Luck.

like image 178
Muhammadalive Avatar answered Feb 19 '26 13:02

Muhammadalive



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!