Skip to main content

Build Status Downloads

Testing and debugging emails while developing a django app has never been pleasant. Sending emails to a file-based backend requires a user to click through obtusely named files and does not provide a way to preview rendered html. Sending email to a valid mailbox incurs a delay as the email is processed though a mail server,and cutters a developer’s inbox.

The mail panel attempts to address these problems by providing a way to preview emails within the browser.

This mail panel is released under the Apache license. If you like it, please consider contributing!

Special thanks to @ShawnMilo for the code review.

Installation

To install the mail panel, first install this package with pip install django-mail-panel. Then add the mail_panel app after debug_toolbar to the INSTALLED_APPS setting:

INSTALLED_APPS = (
    ...
    'debug_toolbar',
    'mail_panel',
)

and add the panel DEBUG_TOOLBAR_PANELS:

DEBUG_TOOLBAR_PANELS = (
    ...
    'mail_panel.panels.MailToolbarPanel',
)

If you use the DEBUG_TOOLBAR_PANELS to custom order your panels:

DEBUG_TOOLBAR_PANELS = [
    'debug_toolbar.panels.versions.VersionsPanel',
    'debug_toolbar.panels.timer.TimerPanel',
    'debug_toolbar.panels.settings.SettingsPanel',
    'debug_toolbar.panels.headers.HeadersPanel',
    'debug_toolbar.panels.request.RequestPanel',
    'debug_toolbar.panels.sql.SQLPanel',
    'debug_toolbar.panels.staticfiles.StaticFilesPanel',
    'debug_toolbar.panels.templates.TemplatesPanel',
    'debug_toolbar.panels.cache.CachePanel',
    'debug_toolbar.panels.signals.SignalsPanel',
    'debug_toolbar.panels.logging.LoggingPanel',
    'debug_toolbar.panels.redirects.RedirectsPanel',
    'mail_panel.panels.MailToolbarPanel',
]

Collect static and you’ll be good to go.

./manage.py collectstatic

Configuration

After installation, you now need to redirect mail to the mail toolbar. Change your email backend to the following:

EMAIL_BACKEND = 'mail_panel.backend.MailToolbarBackend'

By default, mail toolbar stores messages for one day before removing them from cache. You can change this with the following setting:

MAIL_TOOLBAR_TTL = 86400  # 1 Day

Testing

To preview emails sent from your test suite, add the email backend override to your tests with the following: from django.test.utils import override_settings

@override_settings(EMAIL_BACKEND='mail_panel.backend.MailToolbarBackend')
def test_send_email(self):
    ...

The backend works similarly to the standard email backend and code should not need to be reworked when using the MailToolbarBackend.

from django.core import mail

original_outbox = len(mail.outbox)
# Send mail ...
assert(len(mail.outbox) == original_outbox + 1)

Download files

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

Source Distribution

django-mail-panel-1.0.6.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_mail_panel-1.0.6-py2.py3-none-any.whl (16.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-mail-panel-1.0.6.tar.gz.

File metadata

File hashes

Hashes for django-mail-panel-1.0.6.tar.gz
Algorithm Hash digest
SHA256 a47af47c86c1597072af0d70b06f697f4dae39fcabc89b168845de8b559acc7f
MD5 a7829967f6c755be9d45ab712716c4d9
BLAKE2b-256 7058fafd3a74c9f1d60ef821ca5b20710527cbc86d3316e41f051adbadebacf7

See more details on using hashes here.

File details

Details for the file django_mail_panel-1.0.6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_mail_panel-1.0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 024d5ccaccd4e72522958c8a0b8e043c5720955d2152814ebb9a5ff8e72bac62
MD5 71b319e2d8bb063c160a18c80fbaf1dd
BLAKE2b-256 e4b20bcf87dd87ca22681c5c45b4150449d01a8fcff24ad600235be9c6ff7788

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page