GithubHelp home page GithubHelp logo

joseamarcucci / sendgrid-parse-api-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sendgrid/sendgrid-parse-api-example

0.0 0.0 0.0 130 KB

Example application using the SendGrid Parse API.

JavaScript 96.31% Shell 3.09% Python 0.60%

sendgrid-parse-api-example's Introduction

sendgrid-parse-api-example

Example application using the SendGrid Parse API.

This application demonstrates how to use SendGrid's Parse API. Additionally, it acts as a boilerplate of code that you can adjust to your own needs. It comes with complete instructions for getting the SendGrid Parse API working.

Getting Started

You will need an account on SendGrid.

Production

1. Deploy to Heroku

Click this button to deploy to Heroku.

Deploy

2. Check for 200 OK

Then you should be able to run the following - receiving a success 200 response.

$ curl -I -X POST http://your-heroku-subdomain.herokuapp.com/inbound

3. Set SendGrid Parse Settings

Next, setup your SendGrid Parsing Incoming Emails setting like the following but with a hostname of your own and the url you deployed this app to. (You'll notice I actually made my hostname a subdomain m.carve.io. You can do the same or the more standard root of your domain.)

4. Configure Your MX Records

Now you have to configure an MX record on the hostname you set above. It should look something like the following.

Now wait a couple hours to 48 hours. (It can take up to 48 hours for MX records to propagate around the world.)

5. Send an Email

Send an email to [email protected] and this app will now parse it.

It will deliver an email back to you with an attachment containing the content of the webhook data. The contents will look something like this.

6. Adjust the code

You can now adjust the code in routes/inbound.js to do whatever logic you require.

Development

1. Set ENV vars

$ mv .env.example .env

Change the contents of .env to your username and password.

SENDGRID_USERNAME=your_sendgrid_username
SENDGRID_PASSWORD=your_sendgrid_password

2. Run App

$ npm install
$ node app.js

3. Setup ngrok

Detailed install instructions here.

$ wget https://dl.ngrok.com/darwin_amd64/ngrok.zip
$ unzip ngrok.zip -d /usr/local/bin
$ ngrok 3000

Note the url the ngrok command gives you.

4. Set SendGrid Parse Settings

Next, setup your SendGrid Parsing Incoming Emails setting like the following but with a hostname of your own and the url granted to you from the ngrok command above plus the /inbound path.

5. Configure Your MX Records

Now you have to configure an MX record on the hostname you set above. It should look something like the following.

Wait 1-48 hours. (It can take up to 48 hours for MX records to propagate around the world.)

6. Send an Email

Send an email to [email protected] and this app will now parse it.

It will deliver an email back to you with an attachment containing the content of the webhook data. The contents will look something like this.

Alternatives

If you just need a quick way to inspect the payload contents of the Parse API webhook, I recommend using one of the following. You'll still have to setup your MX records.

sendgrid-parse-api-example's People

Contributors

motdotla avatar joseamarcucci avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.