Skip to main content

Django email backend that writes messages to logger instead of sending them by SMTP.

Project description

Django EmailLog Backend

Latest PyPI Version PyPI pyversions PyPI - Django Version

Simple email backend for Django that writes messages to logger instead of sending them to a SMTP server.


Installation is easy using pip

pip install django-emaillog-backend


To ensure that all emails sent using the send_mail function of Django are sent to a log you must add the following line to your file:

EMAIL_BACKEND = 'django_emaillog_backend.backends.LoggerBackend'

You can specify the logger to which the logs will be sent adding it to the file

EMAIL_LOGGER_NAME = 'your_logger_name'

For example, you can create a custom logger to test the correct behaviour of sending mails as follow:

# Add a custom logger to test mails
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
    'handlers': {
    'loggers': {
        'email_logger': {
            'handlers': ['your_handler'],
            'propagate': True,
            'level': 'DEBUG',

# Configure the email backend
EMAIL_BACKEND = 'django_emaillog_backend.backends.LoggerBackend'

EMAIL_LOGGER_NAME = 'email_logger'

The default logger for django-emaillog-backend is the global Django logger called 'django'.

It is also possible to choose the severity level of messages sent to the logger adding the following to your file:

EMAIL_LOGGER_LEVEL = logger_level

EMAIL_LOGGER_LEVEL expects an integer. We recommend using the severity levels of the logging module:

logging.DEBUG (10)
logging.INFO (20)
logging.WARNING (30)
logging.ERROR (40)
logging.CRITICAL (50)

For example:

import logging

The default log level is INFO.

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-emaillog-backend-0.1.2.tar.gz (4.1 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page