Sendgrid Parse is an incoming event API which will analyse and parse incoming emails and POST them on a specific url as a JSON with a multipart encoding
Django Sendgrid Parse allows you to save all the information redirected from Sendgrid Parse to our Django project.
pip install django-sendgrid-parse
-
Add django_sendgrid_parse to your
INSTALLED_APPS
-
In order to use the TransactionalEmail, you need to add the API key in your settings configuration the variable
DJANGO_SENDGRID_PARSE_API='Your-API-key'
and by usingfrom django_sendgrid_parse.emails import TransactionalEmail
you can use this functionality. -
Add to urls.py
url("sendgrid", include("django_sendgrid_parse.urls"))
-
Associate the Domain/Hostname and the URL in the Parse API settings page. The Parse API settings page is here
-
This application executes a signal when an email is received, in case you wish to do something with the message after the save but before informing Sendgrid about the reception. The signal is in:
from django_sendgrid_parse.signals import message_received
and use theemail
parameter. (In case of error in your code, this library will return a 208 status to Sendgrid to stop the multiple retries).
class TransactionalEmail ¶
The EmailMessage
class is initialized with the following parameters
(in the given order, if positional arguments are used). All required
parameters must be set prior to calling the send()
method.
subject
: Required. The subject line of the email.
template_id
: Required. The transactional template ID used in Sendgrid.
body
: Required. The body text with which the template will be filled. This should be a
dictionary.
from_email
: Optional. The sender’s address. Both [email protected]
and Fred <[email protected]>
forms are accepted. If omitted, the
DEFAULT_FROM_EMAIL
setting is used.
to
: Optional. A list or tuple of recipient addresses.