Simple wrapper around django-ses to receive and persist sns event data
Project description
django-ses-sns-tracker
A simple wrapper around django-ses to receive and persist sns event data.
Records mail delivery in the SESMailDelivery
model and updates the state if a matching SNS notification is received.
Requirements
- Django version 3.2+
- A PostgreSQL Database
Quick start
-
Add
ses_sns_tracker
to your INSTALLED_APPS setting like this:INSTALLED_APPS = [ # ... 'ses_sns_tracker', ]
-
Run
python manage.py migrate
to create the models. -
Setup
django-ses
-
Add the webhook view to
urls.py
:from django_ses.views import SESEventWebhookView urlpatterns = [ # ... path('ses-events/', SESEventWebhookView.as_view(), name='handle-event-webhook'), # ... ]
-
(Optional) Use
ses_sns_tracker.backends.SESSNSTrackerBackend
as your default email backend:EMAIL_BACKEND = 'ses_sns_tracker.backends.SESSNSTrackerBackend'
This way all emails will be sent via the Amazon SES API.
-
(Optional) Send an email via the
SESMailDelivery
manager (doesn't requireSESSNSTrackerBackend
as the default mail backend):from django.core.mail import EmailMessage from ses_sns_tracker.models import SESMailDelivery message = EmailMessage( subject='email subject', body='email body', from_email='sender@example.com', to=['recipient@example.com'], ) SESMailDelivery.objects.create_message(message, fail_silently=False, fake_delivery=False)
Settings
-
SES_SNS_TRACKER_DEBUG_BACKEND = 'django.core.mail.backends.console.EmailBackend'
Set mail backend to use for the actual mail delivery in
DEBUG
mode (SESMailDelivery
objects will still be created). Default:None
Development setup
-
Install development dependencies:
poetry install
-
Install the ruff extension for code linting & formatting in your IDE.
-
(Optional) Override settings in
example_proj/settings_local.py
&tests/settings_local.py
as required.
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
Hashes for django_ses_sns_tracker-4.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d764a188fbfd866797aeed665d173271f12c8bb6372e3d168a35c868d46f4e77 |
|
MD5 | b49ea807e4b9f5aaa5cc0cc0c93ef20a |
|
BLAKE2b-256 | d6a2d820f058e208d7572c77d8d01ea8905108a87863d3b8cf72e9ba6c919eca |
Hashes for django_ses_sns_tracker-4.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a48ddd4154bd6cb4caf9195403800b3c06d0bd41fac443a6f00a638c102972b8 |
|
MD5 | b05df4236d66ac0a211134aaa895293f |
|
BLAKE2b-256 | 8ac02d370b0a0b08d75a73fa08bfc269c8dda764cfb836b70f7f3f4ef042c8d9 |