I created the following entries in my ‘settings.py’ file
# Email setup
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'someone@someorg.com'
EMAIL_HOST_PASSWORD = 'thepassword'
EMAIL_PORT = 587
Then I issued the following command in the terminal:
email = EmailMessage('Hello','Have you received this mail?',to=['someone@gmail.com'])
I got 1 as an ouput.
When I checked the mailbox at ‘someone@gmail.com’,no mail was there in the mailbox.Did I miss something?
You should setup
from_emailparameter (as a kwarg or 3rd arg) withEmailMessagecall. Or define in settings.py:This is taken as default if no
from_emailis provided toEmailMessage.On a semi-related note, it’s probably a good idea to also define
SERVER_EMAILin settings.py. This one is used withmail_adminsandmail_managersby Django.