0

How can I solve this problem?

EMAIL_HOST_USER = os.environ.get('mymail@gmail.com')

EMAIL_HOST_PASSWORD = os.environ.get('generatedpassword')

I have generated google app password and put both email and pass on the correct field, still I got this error. Is there any steps to follow?

Community
  • 1
  • 1

1 Answers1

0

Do you actually have environment variables set for EMAIL_HOST_USER and EMAIL_HOST_PASSWORD? os.environ.get takes a key corresponding to a system environment variable as the argument, and will return None by default if an environment variable matching that key cannot be found.

What is happening right now is it's looking for an environment variable called mymail@gmail.com, and because that likely does not exist, it returns None and causes the error you're experiencing.

You should set up an environment variable EMAIL_HOST_USER with a value of mymail@gmail.com, and another with the key being EMAIL_HOST_PASSWORD with value generatedpassword for what you are doing to work.

Note that you can call them something else if you prefer, the name does not have to match the Django settings variable.

See this Stack Overflow post for more information on using os.environ.get().

Mihai Chelaru
  • 7,614
  • 14
  • 45
  • 51