A Django email backend for Amazon SES with bounce and complaint handling
Project description
Django AWS SES
(Badge to be activated upon PyPI release)
A Django email backend for sending emails via Amazon Simple Email Service (SES).
Features
- Send emails using AWS SES with optional DKIM signing.
- Handle bounce, complaint, and delivery notifications via SNS webhooks.
- Filter recipients based on bounce/complaint history and domain validation.
- Admin dashboard for SES statistics and verified emails.
- Secure unsubscribe functionality with confirmation step.
Installation
pip install django_aws_ses
Requirements
- Python 3.8+
- Django 3.2+
- AWS SES account with verified domains/emails
Quick Start
-
Install the package:
pip install django_aws_ses
-
Add to
INSTALLED_APPSinsettings.py:INSTALLED_APPS = [ ... 'django_aws_ses', ]
-
Configure AWS SES settings in
settings.py:AWS_SES_ACCESS_KEY_ID = 'your-access-key' AWS_SES_SECRET_ACCESS_KEY = 'your-secret-key' AWS_SES_REGION_NAME = 'us-east-1' AWS_SES_REGION_ENDPOINT = 'email.us-east-1.amazonaws.com' EMAIL_BACKEND = 'django_aws_ses.backends.SESBackend'
-
Apply migrations:
python manage.py migrate
-
Test email sending:
from django.core.mail import send_mail send_mail('Subject', 'Message', 'from@example.com', ['to@example.com'])
Advanced Setup
DKIM Signing (Optional)
To enable DKIM for email authentication:
-
Generate a DKIM key pair and configure in AWS SES.
-
Add to
settings.py:DKIM_DOMAIN = 'example.com' DKIM_PRIVATE_KEY = 'your-private-key' DKIM_SELECTOR = 'ses'
SNS Webhook for Notifications
To handle bounces, complaints, and deliveries:
- Set up an SNS topic in AWS and subscribe the URL
your-domain.com/aws_ses/bounce/. - Ensure the view is publicly accessible and CSRF-exempt (configured by default).
Unsubscribe Functionality
- Users receive a secure unsubscribe link (
/aws_ses/unsubscribe/<uuid>/<hash>/). - A confirmation page prevents accidental unsubscribes (e.g., by email scanners).
- Re-subscribe option available on the same page.
Usage
- Send Emails: Use Django’s
send_mailorEmailMessageas usual. - View Statistics: Access
/aws_ses/status/(superuser only) for SES quotas and sending stats. - Manage Unsubscribes: Users can unsubscribe or re-subscribe via the secure link.
Development
Running Tests
-
Install test dependencies:
pip install -r requirements-dev.txt
-
Run tests:
python manage.py test django_aws_ses
Contributing
-
Clone the repo:
git clone https://git-vault.zeeksgeeks.com/zeeksgeeks/django_aws_ses
-
Install dependencies:
pip install -r requirements.txt
-
Create a feature branch and submit a pull request.
License
MIT License. See LICENSE for details.
Credits
Developed by Ray Jessop. Inspired by django-ses.
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
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_aws_ses-0.1.0.tar.gz.
File metadata
- Download URL: django_aws_ses-0.1.0.tar.gz
- Upload date:
- Size: 86.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b670607b62a107a37181ce5c7b91718bf13abf2ffe7eb9388f62bfbe7ee327ef
|
|
| MD5 |
51354f0bd687f790ca7dea18e2b5b4ad
|
|
| BLAKE2b-256 |
db2403907fabac87e73a0cd82529fcfd1382b580601ec9071af8d94efd629faf
|
File details
Details for the file django_aws_ses-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_aws_ses-0.1.0-py3-none-any.whl
- Upload date:
- Size: 88.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d832d2388622b97c2a5714459ff6b3c3e968da9ddc2c4e92b113d446abd46750
|
|
| MD5 |
76481690e0b836e3b02c37263dabcd41
|
|
| BLAKE2b-256 |
da7744e4d0d66dc67ea07c6f33db380dd10c1d1e98d29191044796c4b4843058
|