Skip to main content

A Django email backend for hijacking email sending in a staging/test environment. It extends the default SMTP backend to intercept outgoing emails and instead send them to a single email address that you specify. It does not intercept emails going to the site admins (as defined by the ADMINS setting) so it will not interfere with 500 error emails.

You can also configure the hijacked emails to be logged through standard Python logging. Mixin classes are provided to use the same hijack logic for any existing email backend such as django-ses.

Requirements

  • Python 3

  • Django >= 2.2 (supported versions)

Installation

To install django-email-bandit via pip:

pip install django-email-bandit

Add django-email-bandit to your installed apps:

INSTALLED_APPS = (
    ...
    'bandit',
    ...
)

For your test environment you should enable the backend:

EMAIL_BACKEND = 'bandit.backends.smtp.HijackSMTPBackend'

and set the email which will receive all of the emails:

BANDIT_EMAIL = 'bandit@example.com'

or even multiple addresses:

BANDIT_EMAIL = ['bandit@example.com', 'accomplice@example.com']

It’s also possible to whitelist certain email addresses and domains:

BANDIT_WHITELIST = [
    'iloveemail@example.com',  # Just this specific email address
    'example.net'   # All email addresses @example.net
]

Documentation

Full project documentation is on Read the Docs.

Maintainer Information

We use Github Actions to lint (using pre-commit, black, isort, and flake8), test (using tox and tox-gh-actions), calculate coverage (using coverage), and build documentation (using sphinx).

We have a local script to do these actions locally, named maintain.sh:

$ ./maintain.sh

A Github Action workflow also builds and pushes a new package to PyPI whenever a new Release is created in Github. This uses a project-specific PyPI token, as described in the PyPI documentation here. That token has been saved in the PYPI_PASSWORD settings for this repo, but has not been saved anywhere else so if it is needed for any reason, the current one should be deleted and a new one generated.

As always, be sure to bump the version in bandit/__init__.py before creating a Release, so that the proper version gets pushed to PyPI.

Questions or Issues?

If you have questions, issues or requests for improvements please let us know on Github.

Development sponsored by Caktus Consulting Group, LLC.

Release files for django-email-bandit 2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-email-bandit 2.0
File Size Uploaded
django-email-bandit-2.0.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-email-bandit 2.0
File Interpreter ABI Platform
django_email_bandit-2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 20.3 kB

Release files / django-email-bandit-2.0.tar.gz

Download URL django-email-bandit-2.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
676174702b57d1e1f4d74e507fc6bc0e6292e3af08f20088dc4f859614710706
BLAKE2b-256 checksum
How to use checksums
ec5c3246544486a3215d905385a14e34a76cfaf60ff7a90613baa6d968fed1e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

Release files / django_email_bandit-2.0-py2.py3-none-any.whl

Download URL django_email_bandit-2.0-py2.py3-none-any.whl
Size 10.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
22b0a3ebf2ac19051facc2148df338f353a749d9e3e3bce6551fffcbbe049d0a
BLAKE2b-256 checksum
How to use checksums
f2eb798812481e102792fdac554b18ca93950fe129b9a0091868a894ed41bf44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

Release history Release notifications | RSS feed

This release

2.0 This release

2 release files

1.6

2 release files

1.5

2 release files

1.4

2 release files

1.3

2 release files

1.2

1 release file

1.1

1 release file

1.0

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page