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 2.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
(useSESSNSTrackerWebhookView
instead ofSESEventWebhookView
fromdjango_ses
):from ses_sns_tracker.views import SESSNSTrackerWebhookView urlpatterns = [ # ... path('ses-events/', SESSNSTrackerWebhookView.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 send 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
-
SES_SNS_TRACKER_USE_CRYPTOGRAPHY = True
Use
crypthography
instead ofM2Crypto
to verify the signature of messages received from SNS. Default:True
Development setup
-
Upgrade packaging tools:
pip install --upgrade pip setuptools wheel
-
Install packages from
requirements-dev.txt
:pip install -r requirements-dev.txt
-
(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-2.0.0rc1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2dbadf0374627f49add891eebe7dccfa7d0dc3fded63554b1b67119d4605a66 |
|
MD5 | 5125262671bc5b450a505ffe2f7144d5 |
|
BLAKE2b-256 | 4141cc622bd3296c9bc29331e74b15ef8c144fa6e0a8ca612820f1dcc1d120ba |
Hashes for django_ses_sns_tracker-2.0.0rc1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9df2a7fa6a7cb9460967fded465bd686baaa2ada2cbc80182eb8fee002c2f58f |
|
MD5 | 8ca8c3f7918c9db89db38175af27214e |
|
BLAKE2b-256 | 08ad8cff4ef208b0a1f1e112c7ea53c042ee2bc372bf1c611651b0c129942c82 |