Skip to main content

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

Project description

https://badge.fury.io/py/dj-email-url.svg

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.

Usage

Import the package in settings.py:

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_FILE_PATH = email_config['EMAIL_FILE_PATH']
EMAIL_HOST_USER = email_config['EMAIL_HOST_USER']
EMAIL_HOST_PASSWORD = email_config['EMAIL_HOST_PASSWORD']
EMAIL_HOST = email_config['EMAIL_HOST']
EMAIL_PORT = email_config['EMAIL_PORT']
EMAIL_BACKEND = email_config['EMAIL_BACKEND']
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:

vars().update(email_config)

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://user@domain.com:pass@smtp.example.com:465/?ssl=True'
>>> 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.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):

https://travis-ci.org/migonzalvar/dj-email-url.svg?branch=master https://codecov.io/gh/migonzalvar/dj-email-url/branch/master/graph/badge.svg

Project details


Download files

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

Source Distribution

dj-email-url-0.0.8.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

dj_email_url-0.0.8-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dj-email-url-0.0.8.tar.gz.

File metadata

File hashes

Hashes for dj-email-url-0.0.8.tar.gz
Algorithm Hash digest
SHA256 224dbdd28b8fe744de75783808030c71464ee63bcafee34fa3d243592ffec4b5
MD5 cd3a749776d38135a8957784a4910884
BLAKE2b-256 838b1545ec5b6a36f84e42255b0eca07cce63b41188258b8bed3c67a06671e09

See more details on using hashes here.

File details

Details for the file dj_email_url-0.0.8-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for dj_email_url-0.0.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0cf4142cdda59cd023d56cc50f2d6e425a509eb031f08cff0403175d88131f30
MD5 a3b077d6a0448e9242998a37880c2984
BLAKE2b-256 54500395d982ecb764221348334b27e76c265ca0fe00de8da53081bbcec5f1bb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page