SendGrid Inbound Parse Emails

Parses SendGrid’s Inbound Parse Emails into a dictionary of fields from POST parameters.

The Parse API will POST the parsed email to a URL specified in the Sendgrid settings. If POST is unsuccesful, SendGrid automatically queues and retries any POSTs that respond with a 4XX or 5XX status. To prevent redelivery or queueing of the mail, respond with 2XX. Messages that cannot be delivered after 3 days will be dropped.

See SendGrid documentation for more details.

POST Parameters

The POST parameters are available from the returned dictionary with the following keys:

Helper utilities

The sendgrid_parse.helpers contains utilities for flask and django that use the correct request variables to access the POST data and attachments. These are wrappers around the parse method and do not contain any framework specific except for naming and access conventions.

Usage

The package is available under sendgrid_parse.

To install, use: pip install sendgrid_parse

# plain python (args: POST dictionary, files dictionary)
from sendgrid_parse import parse
mail = parse(post_dict, file_dict)


# for frameworks:
# flask
from sendgrid_parse.helpers.flask import parse
# django
from sendgrid_parse.helpers.django import parse

# use:
mail = parse(request)
      

Code Documentation

Github code

Contains the hosted code repository. Issues / Bugs / Requests to be kindly taken up there.