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:

    from django_ses.views import SESEventWebhookView
    
    urlpatterns = [
        # ...
        path('ses-events/', SESEventWebhookView.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 sent 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

Development setup

  1. Install development dependencies:

    poetry install
    
  2. Install the ruff extension for code linting & formatting in your IDE.

  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-4.0.0rc1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django_ses_sns_tracker-4.0.0rc1.tar.gz.

File metadata

File hashes

Hashes for django_ses_sns_tracker-4.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 658aaac2daeaceeac65d1b97c4b50d469d16772acb31734db34f11d5c5bc88c8
MD5 490d4a8c1b1e134905fa749bf9520650
BLAKE2b-256 e4d493c14da9e905d4a16a788585f5b75573f3bf8f79bc302a58a9a4ab8510a4

See more details on using hashes here.

File details

Details for the file django_ses_sns_tracker-4.0.0rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ses_sns_tracker-4.0.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 221c5c0cc5862b95edfdf42d5ed6bb099ce58bdf5bddcafea54af9f618cd3d27
MD5 665c1af70c88f7e9b665bc49c8c93e73
BLAKE2b-256 7c23b83720315f3e974774b45df9e135f81d76c8003cd3f86aacb01b127ee5e8

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