django-sendgrid-webhook 0.2.2

A small django app around sendgrid and its webhooks


Platform: Pypi

Language: Python

License: BSD-3-Clause-Clear

View on registry:

Build Status Join the chat at


This django app enables you to send emails to sendgrid and receive callbacks to monitor the status of all your emails. You can also attach them to a related object in your own app. A signal will be dispatched every time a new callback is received (and also when the email is created for the first time). We also provide helper classes which inherit from the email classes in django.core.mail which means you can transparently switch out the django classes with ours.


  1. pip install django-sendgrid-webhook
  2. Add app to INSTALLED_APPS

    INSTALLED_APPS += 'sendgrid'
  3. South compatibility (Django < 1.7)

    If you're using Django >= 1.7 you don't have to do anything. For users with older versions, South tries to use the new Django migrations instead of the South migrations. Please add the following code snippet to your settings:

     'sendgrid': 'sendgrid.south_migrations',
  4. Run python syncdb to install the new Email model
  5. Include sendgrid.urls at some point in your url structure. E.g. in /

    # Sendgrid event hooks
    urlpatterns += patterns(
     url(r'^', include('sendgrid.urls')),

    This will add the callback path /sendgrid_callback/.

  6. Go to and add the App Event Notification.
  7. Configure the App to send the events you'd like to and add the Callback URL. If you included sendgrid.urls like mentioned above it would be :


Our classes in sendgrid.utils are inheriting from the default classes of django.core.mail, so you just need to configure your SMTP settings as shown in to use them.

Configuration Options

Currently we only have one configuration option which can be added to the django settings.

Adding SENDGRID_EVENTS_IGNORE_MISSING = True to your settings will silently ignore callbacks for emails which are sent without a UUID. This is very helpful because Sendgrid would otherwise receive a non-200 answer from our webhook and would try to re-deliver the same message for 24h until giving up sending messages altogether. So unless you're very sure this will never happen, you should probably enable this.


In theory you can send messages yourself by adding a UUID parameter to the unique_args parameter in the SMTP header X-SMTPAPI as specified in . But you can also save yourself the work and read the next section.

Sending emails (the easy way)

sendgrid.utils.SendgridEmailMessage and sendgrid.utils.SendgridEmailMultiAlternatives can be used instead of the Django versions in django.core.mail. In fact the easiest transition is to just replace every use of from django.core.mail import EmailMessage with from sendgrid.utils import SendgridEmailMessage as EmailMessage. From then on every email you send will include an UUID parameter to track the callback, and a new instance of the model sendgrid.models.Email will be created and updated on every callback received.

You can also attach a related object to the Email object by passing an obj parameter in the .send() function of SendgridEmailMessage or SendgridEmailMultiAlternatives.


Every time a new object is created or a callback is received, the signal sendgrid.signals.email_event is dispatched. See for more details on Django signals.

веселые картинки развлекательные гифки интресные факты смешные видео смешные истории из соцсетей

GitHub Repository

resmio/django-sendgrid resmio/django-sendgrid

A small django app around sendgrid and its webhooks

Language: Python

Created: May 27, 2014 15:01

Last updated: March 24, 2015 04:50

Last pushed: March 23, 2015 17:42

Size: 399 KB

Stars: 4

Forks: 1

Watchers: 3

Open issues: 1

Top Contributors

Jann Kleen Niels Sandholt Busch


  • 0.2.2 - March 23, 2015 17:49
  • 0.1.0 - November 28, 2014 12:14

Related Projects

django-badgify 0.1.4
Badges app for Django
Pypi - Python - Other - Updated about 2 months ago - 12 stars
django-pgallery 0.5.1.dev0
Photo gallery app for PostgreSQL and Django.
Pypi - Python - MIT - Updated about 2 months ago - 7 stars
django-eintopf 0.0.1-beta
Collection of small tools and enhancements for Django
Pypi - Python - MIT - Updated about 1 month ago
django-locations-base 0.2.4
A simple locations app for Django
Pypi - Python - MIT - Updated 1 day ago - 1 stars
django-blogg 0.2
Blog app for Django
Pypi - Python - MIT - Updated 27 days ago
веселые картинки развлекательные гифки интресные факты смешные видео смешные истории из соцсетей