I am developing a web-app in Django that needs to send automated emails. The username
and password
are saved locally in my Windows 10
environment variables. The app is able to send emails locally, but in proudction once deployed to Heroku
, the following error is raised:
530, b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError y7sm6660123qtn.11 - gsmtp', 'webmaster@localhost'
My guess is that the environment variables are not being accessed which is why this error is thrown.
Here is my code in settings.py
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = os.environ.get('NAHE-USER')
EMAIL_HOST_PASSWORD = os.environ.get('NAHE-PASS')