Diskdrive
Diskdrive

Reputation: 18825

Receiving email on Meteor?

From the documentation (http://docs.meteor.com/#email), it seems sending email is fairly straight forward with Meteor. Just need to add the package, then specify the credentials of your 3rd party email provider in MAIL_URL.

Currently, I'm trying to develop the ability to receive emails. We need this facility to say unsubscribe a user from our system or allow users to input data by just replying to their email.

I just want to know, what is the best way to do this? Is it possible to receive and parse the emails from within my Meteor solution or do I need to set up something seperate solution to do this?

If it helps, I'm running a meteor website off an azure VM (in ubuntu) and our 3rd party provider is SendGrid.

Upvotes: 6

Views: 2080

Answers (3)

kunal batra
kunal batra

Reputation: 535

I'm also an Evangelist at SendGrid. Here is the procedure for receiving inbound email with our parse webhook in Meteor:

  1. Setup Meteorite a package manager for meteor. Installation procedure here: https://github.com/oortcloud/meteorite

  2. Run mrt add router in the command line.

  3. Next modify your javascript to add a route:

Meteor.Router.add({ '/inbound': function() {

post = this.request.body;

subject = post.subject;

body = post.body;

return [200, "Success"] } });

You can see a live example of receiving inbound email over here: http://hook.meteor.com and the source code for this is available here: https://github.com/kunal732/sgmeteor

Here is a blog post I wrote on the topic as well for more reference, http://sendgrid.com/blog/receive-inbound-email-meteorjs/

Upvotes: 3

scottmotte
scottmotte

Reputation: 634

If you want to receive email, you have 2 major options:

First Option

The first is to setup an email server to receive email, store that email, and access it. I'd recommend Haraka to do this. You can install it on your server, run it, and then add a plugin like haraka-couchdb or haraka-redis to store the emails into a database. Then you could simply query that database and pull the email content out. Then you just have to parse it. (I find this approach easier than setting up postfix with IMAP support and keep that running)

Second Option

The second option is to use SendGrid's Parse Webhook (since you're already a customer with us - disclaimer: I'm a developer evangelist with SendGrid). There's a beginners guide to do this here:

http://sendgrid.com/blog/parse-webhook-tutorial/

And an example application here:

https://github.com/scottmotte/sendgrid-parse-api-example

Upvotes: 2

Christian Fritz
Christian Fritz

Reputation: 21364

You will first need to setup your machine (or another one) to actually be able to receive email. This in itself is a bit of a task and not super straightforward and will involve setting a MX record on your nameserver as well. It will require some reading. This might be a place to get started: https://help.ubuntu.com/12.04/installation-guide/i386/mail-setup.html

Once you have the ability to send email to the server you can use something like this to retrieve emails into node/meteor: https://github.com/mscdex/node-imap https://atmosphere.meteor.com/package/meteor-node-imap

If you'd rather have node.js itself run a smtp server to receive mail, you would probably want to look at something like this: https://npmjs.org/package/simplesmtp

Upvotes: 2

Related Questions