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()
.