Skip to main content

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

Quick start

  1. Add ses_sns_tracker to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        # ...
        'ses_sns_tracker',
    ]
    
  2. Run python manage.py migrate to create the models.

  3. Setup django-ses

  4. Add the webhook view to urls.py (use SESSNSTrackerWebhookView instead of SESEventWebhookView from django_ses):

    from ses_sns_tracker.views import SESSNSTrackerWebhookView
    
    urlpatterns = [
        # ...
        path('ses-events/', SESSNSTrackerWebhookView.as_view(), name='handle-event-webhook'),
        # ...
    ]
    
  5. (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.

  6. (Optional) Send an email via the SESMailDelivery manager (doesn't require SESSNSTrackerBackend 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 of M2Crypto to verify the signature of messages received from SNS. Default: True

Development setup

  1. Upgrade packaging tools:

    pip install --upgrade pip setuptools wheel
    
  2. Install packages from requirements-dev.txt:

    pip install -r requirements-dev.txt
    
  3. (Optional) Override settings in example_proj/settings_local.py & tests/settings_local.py as required.

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

django-ses-sns-tracker-3.0.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

django_ses_sns_tracker-3.0.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file django-ses-sns-tracker-3.0.0.tar.gz.

File metadata

  • Download URL: django-ses-sns-tracker-3.0.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for django-ses-sns-tracker-3.0.0.tar.gz
Algorithm Hash digest
SHA256 5be819183c2bbbab9309b1f8f93ca041c952e0167922b44de69424128ae09fe6
MD5 24bf356b20646936684f465415ad7574
BLAKE2b-256 1f9e9d2ce92470ce9b6350fde06c7051050d551712f371690133f5703027bcc5

See more details on using hashes here.

File details

Details for the file django_ses_sns_tracker-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: django_ses_sns_tracker-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11

File hashes

Hashes for django_ses_sns_tracker-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c96d95468d0f8a0859254f4a78121f2819a99c66fb991764f64b30103b4ce2af
MD5 88f3ee2fe16d40b5378379ab7644aa78
BLAKE2b-256 8c5a791188a6149c12e54423fc462191d2b665c833e98edaf15bf001609ca63a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page