Sendgrid Inbound Email Parsing with django

Using the Inbound parse webhook, we can parse the contents, attachments of an incoming email. 

Inbound Parse API follows 3 steps:

1. sending an email to the mail id(URL_Name@your specified domain/sub domain.com)

        a Here the domain/ sub domain, where the emails will be sent, and the URL_Name, where we will handle the contents, attachments of an incoming email in our app. 

        b. Here the domain/sub domain should point out the MX record to mx.sendgrid.net. Here http://mxtoolbox.com/ you can check weather your domain/ sub domain is having MX  record or not.

        c. we should add domain/ sub domain, URL to our inbound parse webhook settings list.

         For ex:
             domain: reports.micropyramid.com
             url: https://micropyramid.com/reports/
             mail id: reports@reports.micropyramid.com

2. Sendgrid parses the content and attachments of an email and sends the information to the specified URL of your application.

3. You can receive the JSON post response to your application
         envelope = request.POST.get('envelope')
         my_dict = literal_eval(envelope)

      You can get email from address form my_dict['from'], text(request.POST.get('text')), attachment details from request.POST.get('attachment-info').

In order to test it in local server, You can use the following settings:

        domain: your_domain_name.bymail.in(bymail.in is having an MX record)
        URL: Your App Url
        mail id: URL_Name@your_domain_name.bymail.in

 

    By Posted On
SENIOR DEVELOPER at MICROPYRAMID

Latest Comments
Related Articles
Improving page speed score in Google Page Score test- PART1 Chaitanya Kattineni

Google's Page Speed Insights measures the performance of a page for mobile devices and desktop devices. It fetches the url twice, once with a mobile ...

Continue Reading...
Introduction to Django's Class based views - Understanding how a class based view works Ashwin Kumar

Django has MVT architecture. A view in django is just a callable that takes a request and returns a response. But this can be more ...

Continue Reading...
Securing Django with multi factor authentication using Django-MFA Vinisha Naladala

Use Django Multi-Factor Authentication method to verify user identity with more than one authentication methods. It can be used for user login, any transactional methods ...

Continue Reading...

Subscribe To our news letter

Subscribe to our news letter to receive latest blog posts into your inbox. Please fill your email address in the below form.
*We don't provide your email contact details to any third parties