Receive Inbound Email with MeteorJS


Posted on

meteorjsMeteor is a relatively new JavaScript framework that is becoming quite popular. It lets you build real-time web apps rapidly. My fellow developer evangelist @scottmotte has already written about how you send email with Meteor. In this blog post, I want to expand on this and showcase how your Meteor application can receive inbound email, as well.

Route Requests with Meteorite

To receive email, you can use SendGrid’s inbound Parse Webhook. This will POST new emails to any URL you specify. Since we want to receive email with Meteor, we need to add a Meteor route.

Once you have Meteor installed, you want to set up Meteorite to handle packages. Then you can add the router functionality:

mrt add router

Next, modify your JavaScript to add your route and action:

In this case I’m looking at the subject of the email and using that value to update the database.

To make this work in your application, log in to your SendGrid account and point the Parse Webhook to /inbound on your Meteor app. You can test webhooks locally with ngrok, or put it up on your own server.

See This Example Live

To showcase the real-time aspect of Meteor, I made an application that lets you change the background color of the page.

Meteor background color

» Go to hook.meteor.com

Send an email to change@color.bymail.in and in the subject put the color you want.

The source code for the sample app is available on GitHub and for more details on the feature behind this tool, download the Parse Webhook Guide.


Meet Kunal, Developer Evangelist at-large for SendGrid and home-grown New Jersey hacker. He previously ran General Machines, which developed Deaftel - a phone service for the deaf that converts voice to text and text back into voice over a phone call. Since March 2013, Kunal has been working as a Developer Evangelist at SendGrid, helping enable developers to get the tools and resources they need to make awesome, creative stuff.

Kunal Batra on Twitter
Have thoughts on this post?
Chat with us about it on Twitter and Google+