This package implements an email backend for Django that relies on sendgrid's REST API for message delivery.
It is under active development, and pull requests are more than welcome!
To use the backend, simply install the package (using pip), set the EMAIL_BACKEND
setting in Django, and add a SENDGRID_API_KEY
key (set to the appropriate value) to your Django settings.
pip install django-sendgrid-v5
- In your project's settings.py script:
- Set
EMAIL_BACKEND = "sendgrid_backend.SendgridBackend"
- Set the SENDGRID_API_KEY in settings.py to your api key that was provided to you by sendgrid.
SENDGRID_API_KEY = os.environ["SENDGRID_API_KEY"]
- Set
- To toggle sandbox mode (when django is running in DEBUG mode), set
SENDGRID_SANDBOX_MODE_IN_DEBUG = True/False
.- To err on the side of caution, this defaults to True, so emails sent in DEBUG mode will not be delivered, unless this setting is explicitly set to False.
SENDGRID_ECHO_TO_STDOUT
will echo to stdout or any other file-like object that is passed to the backend via thestream
kwarg.SENDGRID_TRACK_EMAIL_OPENS
- defaults to true and tracks email open events via the Sendgrid service. These events are logged in the Statistics UI, Email Activity interface, and are reported by the Event Webhook.SENDGRID_TRACK_CLICKS_HTML
- defaults to true and, if enabled in your Sendgrid account, will tracks click events on links found in the HTML message sent.SENDGRID_TRACK_CLICKS_PLAIN
- defaults to true and, if enabled in your Sendgrid account, will tracks click events on links found in the plain text message sent.