Mr. Editor-in-chief Mr. Editor-in-chief February 1, 2021 Updated April 24, 2026

Send Emails with Django

How to send out emails with Django using Gmail.
Setup a Gmail "App Password"
1. Enable 2-factor authentication. This is required in order to use less secure apps.
2. Navigate to myaccount.google.com/security and scroll down to the "Signing Into Google" section. Click on "App Passwords."
3. You'll be asked to enter your personal Gmail account password. Next, click on "Select App" and input a name for your Django app. Generate an 'App Password'.
4. Copy the generated app password for later usage

Add a few lines on Django settings.py

# Gmail Example
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'your_username@gmail.com'
EMAIL_HOST_PASSWORD = 'generated_app_password_from_above'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False

It's recommended that we don't put secret information such as email password on settings.py. Please refer to How to Use Python Decouple Library for Django Application for more.