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='da24@gmail.com'
  • Comparision 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 gives this error .

Fortunately found the answer later, a reboot of Linux or the bashrc file reload is required . Unless that happens the env won't register that . Also using python console to set env variables does not work, even after reboot.

Hope this helps some beginners like me !!!

Back to Top