Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Use an URL to configure email backend settings in your Django Application.

Project Description

This utility is based on dj-database-url by Kenneth Reitz.

It allows to utilize the 12factor inspired environments variable to configure the email backend in a Django application.


Import the package in

import dj_email_url

Fetch your email configuration values. The default option is fetch them from EMAIL_URL environment variable:

email_config = dj_email_url.config()

Other option is parse an arbitrary email URL:

email_config = dj_email_url.parse('smtp://...')

Finally, it is necessary to assign values to settings:

EMAIL_HOST = email_config['EMAIL_HOST']
EMAIL_PORT = email_config['EMAIL_PORT']
EMAIL_USE_TLS = email_config['EMAIL_USE_TLS']
EMAIL_USE_SSL = email_config['EMAIL_USE_SSL']

Alternatively, it is possible to use this less explicit shortcut:


Supported backends

Currently, it supports:

  • SMTP backend (smtp and smtps for TLS),
  • console backend (console),
  • file backend (file),
  • in-memory backend (memory),
  • and dummy backend (dummy).

SMTP backend

The scheme smtps indicates to use TLS connections, that is to set EMAIL_USE_TLS to True.

It is possible to specify SSL using a ssl=True as a query parameter:

>>> url = 'smtp://'
>>> url = dj_email_url.parse(url)
>>> assert url['EMAIL_USE_SSL'] is True

File backend

The file backend is the only one which needs a path. The url path is store in EMAIL_FILE_PATH key.

Change Log

0.0.10 - 2016-10-14

  • Post release version to fix release date in change log.

0.0.9 - 2016-10-14

  • Fix case when user sets ssl=False in its url (thanks bogdal)

0.0.8 - 2016-06-07

  • Allow universal wheel

0.0.7 - 2016-05-31

  • Add EMAIL_USE_SSL setting to docs and set a default value (thanks iraycd).
  • Add coverage (thanks iraycd).

0.0.6 - 2016-04-18

  • Fix error parsing URL without credentials (thanks martinmaillard).

0.0.5 - 2016-04-17

  • Allow URL encoded credentials (thanks kane-c).

0.0.4 - 2015-03-05

  • Fix README.

0.0.3 - 2015-03-05

  • Add change log.
  • Add ssl= option as a query parameter for SMTP backend.
  • Add Travis continuous integration.

0.0.2 - 2014-03-12

  • Add Python 3 support.

0.0.1 - 2013-02-12

  • Initial version.

CI status

Development (master):

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(5.9 kB) Copy SHA256 Hash SHA256
Wheel py2.py3 Oct 14, 2016
(3.8 kB) Copy SHA256 Hash SHA256
Source None Oct 14, 2016

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting