Giter Site home page Giter Site logo

smileychris / django-mail-panel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scuml/django-mail-panel

0.0 2.0 0.0 85 KB

Preview mail in this panel for django debug toolbar.

License: Other

Python 48.72% CSS 18.72% JavaScript 18.65% HTML 11.82% Shell 2.09%

django-mail-panel's Introduction

Django Debug Toolbar - Mail Panel

Build Status

Testing and debugging e-mail while developing a Django app has never been pleasant. Sending e-mail 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 e-mail to a valid mailbox incurs a delay as the message is processed though a mail server, and clutters a developer's inbox.

The mail panel attempts to address these problems by providing a way to preview emails within the browser using django-debug-toolbar.

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_toolbarto the INSTALLED_APPS setting:

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

and add the panel DEBUG_TOOLBAR_PANELS:

DEBUG_TOOLBAR_PANELS = (
    ...
    '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'

Important: This plugin uses Django's cache backend to store messages. If you are using DummyCache, the mail panel will use a local memory cache, and will reset messages when the server is restarted.

[Optional] 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

[Optional] 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',
    ]

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):
    # your code here

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)

Shameless Plugs

Like Django Mail Panel? Be sure to check out and support these other tools for Mac that will improve your workflow:

Kubermagic - Automate, and script away tedious kubectl commands with Kubermagic; a UI for developers, QA teams, and those starting to learn the ins-and-outs of Kubernetes.

Red - A visual and interactive Redis client, featuring live updating keys, an interactive console, pub/sub, lua script support and much more.

django-mail-panel's People

Contributors

adamb70 avatar benspaulding avatar ciotto avatar hugotacito avatar indrif avatar jensenbox avatar nikicat avatar nschlemm avatar scuml avatar shawnmilo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.