|
||
---|---|---|
django_aws_ses | ||
.gitignore | ||
CONTRIBUTING.md | ||
LICENSE | ||
MANIFEST.in | ||
README.md | ||
requirements-dev.txt | ||
requirements.txt | ||
setup.py |
README.md
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_APPS
insettings.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_mail
orEmailMessage
as 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.