Django email backend that writes messages to logger instead of sending them by SMTP.
Project description
Django EmailLog Backend
Simple email backend for Django that writes messages to logger instead of sending them to a SMTP server.
Installation
Installation is easy using pip
pip install django-emaillog-backend
Usage
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 settings.py file:
EMAIL_BACKEND = 'django_emaillog_backend.backends.LoggerBackend'
You can specify the logger to which the logs will be sent adding it to the settings.py 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
LOGGING = {
'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 settings.py 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
EMAIL_LOGGER_LEVEL = logging.INFO
The default log level is INFO.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-emaillog-backend-0.1.2.tar.gz.
File metadata
- Download URL: django-emaillog-backend-0.1.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
623ec317e64db7ac05ee7b94b399ab81fbe37dc700121197b29d74cf1bb26e4a
|
|
| MD5 |
76cc028bfe028ab9bfa854f18185f00b
|
|
| BLAKE2b-256 |
52544c5b4472347c36e9b54e21ffe5da6128787a824822966685763ce2f9214d
|
File details
Details for the file django_emaillog_backend-0.1.2-py3-none-any.whl.
File metadata
- Download URL: django_emaillog_backend-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ce48630c00829ff3721945aa4273dbdd04b2ae9b9d23bd396c22b99a5bd9f8c
|
|
| MD5 |
587307479d01d37514f53717e7b18b71
|
|
| BLAKE2b-256 |
f5abb63f1c1553df86ec2abaff06f06b4bdbdb51ef500bd53a10356a07044dcf
|