Skip to main content

A panel for django-debug-toolbar that allows for viewing of recently sent email.

Project description


## Django Debug Toolbar - Mail Panel

[![Build Status](https://secure.travis-ci.org/scuml/django-mail-panel.png?branch=master)](http://travis-ci.org/scuml/django-mail-panel)
[![Downloads](https://img.shields.io/pypi/dw/django-mail-panel.svg)](https://pypi.python.org/pypi/django-mail-panel)


![Screeny](https://cloud.githubusercontent.com/assets/1790447/9289964/6aa7c4ba-434e-11e5-8594-3bb3efd0cd81.png)


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, all the while adding clutter to a developer's inbox, and even occasionally finds itself buried in a spam directory.

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

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-debug-toolbar-mail`, then add mail_panel after debug_toolbar to 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)

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

django-mail-panel-1.0.1.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

django_mail_panel-1.0.1-py2.py3-none-any.whl (13.9 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for django-mail-panel-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3f74f0f030f1618cbb5d53fbe710449cfffaa5cdf83f8c0c11ef8615c19afa54
MD5 88425ac84e7ee7d4d240f46e00fffa2e
BLAKE2b-256 bab6df09f2fca8cf8c92171a1cdb4b1e2a0c5c28c117b4f2563b0528d6d426ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_mail_panel-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 69436a2ee082f6ff9b629d6404bb09e90e2b881f15aba8db56591db89743c9e6
MD5 cd6760a708e51233d69e0abb1ce34624
BLAKE2b-256 877464b2ea2420dd14d958e7264cab6ef9ae0ef4191de60fd9d20c452643e6d4

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page