Setting up mail in Django

Setting up mail in Django is actually a very simple operation. It is enough to add the following lines to the settings.py project settings:

EMAIL_HOST = 'smtp.email-domain.com'
EMAIL_HOST_USER = 'yourusername@youremail.com'
EMAIL_HOST_PASSWORD = 'your_password'
# if a secure connection is used
EMAIL_PORT = 587
EMAIL_USE_TLS = True

How to receive project errors on Django to your mail?

ADMINS = (
    ('You', 'you@email.com'),
)
MANAGERS = ADMINS

Mail testing during project development

While the project is being developed (in DEBUG = True mode), instead of sending mail through the mail service, you can use the console (i.e. all sending emails will be displayed in the console in the running project ./manage.py runserver)

if DEBUG:
    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
else:
    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
Back to Top