https://github.com/openlibhums/django_selective_email_backend
Selects between django_mailgun and the builtin SMTP backend depending on the set from address.
https://github.com/openlibhums/django_selective_email_backend
Last synced: 4 months ago
JSON representation
Selects between django_mailgun and the builtin SMTP backend depending on the set from address.
- Host: GitHub
- URL: https://github.com/openlibhums/django_selective_email_backend
- Owner: openlibhums
- License: agpl-3.0
- Created: 2024-10-10T08:30:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-25T09:31:07.000Z (10 months ago)
- Last Synced: 2025-07-25T15:37:34.686Z (10 months ago)
- Language: Python
- Size: 24.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Django Selective Email Backend
A Django email backend that dynamically selects between Django's SMTP backend and a configurable email backend based on the sender's email address. Configure specific email addresses to use SMTP while falling back to a default backend for all other addresses.
## Features
- Automatically routes emails based on the sender's address.
- Uses SMTP for specific addresses defined in your Django settings.
- Defaults to a configurable backend (eg django_mailgun) for all other addresses.
- Simple integration with existing Django projects.
## Installation
Install directly from GitHub using `pip`:
```bash
pip install -e git+ssh://git@github.com/openlibhums/django_selective_email_backend@v0.0.2#egg=django-selective-email-backend
```
## Configuration
Add the backend to your settings.py:
```python
EMAIL_BACKEND = 'selective_email_backend.backends.SelectiveEmailBackend'
```
Define the SMTP email addresses and other relevant settings:
```python
# settings.py
INSTALLED_APPS = [
...
'selective_email_backend',
...
]
DEFAULT_EMAIL_BACKEND = 'django_mailgun.MailgunBackend'
SMTP_EMAIL_ADDRESSES = [
'janeway@janeway.systems',
'chakotay@janeway.systems',
]
# Mailgun settings
MAILGUN_ACCESS_KEY = 'mailgun-access-key'
MAILGUN_SERVER_NAME = 'mailgun-server-name'
# SMTP settings
EMAIL_HOST = 'smtp.janeway.systems'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'smtp-user-name'
EMAIL_HOST_PASSWORD = 'smtp-password'
```