django-email-log

Django-email-log is a Django app that logs all outgoing emails to the database.

All emails are logged in an Email model and emails may be viewed from the admin site. When an email fails to send the error is noted in the model also.

Django-email-log can also be used with other custom email backends by setting the EMAIL_LOG_BACKEND setting to your custom email backend.

Warning

This app should not be used if outgoing emails may contain sensitive information that shouldn’t be logged in the database!

Contents:

Usage

Installation

Install from PyPI:

$ pip install django-email-log

Quickstart

Add email_log to INSTALLED_APPS in your settings file:

INSTALLED_APPS = (
    ...
    'email_log',
)

Then set django-email-log as your email backend in your settings file:

EMAIL_BACKEND = 'email_log.backends.EmailBackend'

By default attachments will not be saved to the database. If you want all attachments to be saved to the database, just set this to true:

EMAIL_LOG_SAVE_ATTACHMENTS = True

And using this setting you can configure path to your attachments:

EMAIL_LOG_ATTACHMENTS_PATH = "path/to/attachments"

Using with other email backends

By default django-email-log uses Django’s SMTP backend to send emails. The EMAIL_LOG_BACKEND setting should be specified if you are using a custom email backend. For example:

EMAIL_LOG_BACKEND = 'yourapp.backends.YourCustomEmailBackend'

If you are using an email queueing backend such as django-celery-email, the django-email-log backend should be used behind the queuing backend so errors will be logged properly. For example with django-celery-email this should work:

CELERY_EMAIL_BACKEND = 'email_log.backends.EmailBackend'

Visit the project on Github to view the source, submit issues and pull requests.