Rails 3 - Handle Incoming Messages (Allowing Users to reply to email notifications) - ruby-on-rails

Right now my app sends out email notifications. I'd like to allow the user to reply directly to the email, which then gets ingested by my app and inserted into the database.
Are there any Rails gems, services, tutorials that can point me in the right direction.
Also, probably need to make the reply-to email have a UID, replyto--UID#domain.com, so I don't have to rely on the from (sender).
What do you think?
Thanks

A few good articles to get you started:
http://railstips.org/blog/archives/2008/10/27/using-gmail-with-imap-to-receive-email-in-rails/
http://jasonseifer.com/2009/04/24/receving-email-with-rails

We have a free service that posts incoming email to a url of your application (same as sendgrid API):
http://www.smtp2web.com
You can also use the mailman gem if you want to poll for the email at regular intervals:
https://github.com/titanous/mailman
As far as the 'replyto--UID#domain.com' kind of email addresses are concerned, you will have to create a catch-all address for your domain (it is better if you use a obscure subdomain, as it would reduce the amount of spam) which forwards all such email to a given mailbox(say notifications#domain.com).

I would highly recommend using CloudMailin for the same.
It provides you a receiving email address, which you can add as a reply-to header in your mail.
About the unique UID, for tracking each reply in context of the sent email, you could generate a random string, and modify your reply-to header as "[email provided by cloudmailin]+[your random string]"

You'd need to look at configuring your sendmail/postfix to accept incoming mail first off ( if you're using unix based server ).
Heres a good article:
http://jasonseifer.com/2009/04/24/receving-email-with-rails

You can use Sendgrid to parse incoming email and have it send along to your app via a web-post.
This is a decent tutorial (heroku focused)
Or you can view Sendgrid's ParseAPI to see how to integrate.

Related

How to programmatically parse emails on an Outlook server and execute a script/task

My intranet web application (written in C#/ASP.Net MVC) sends email notifications in certain situations. I would like to intercept replies to such emails and perform actions based on the content of such replies.
I have no preference for scripting language - it could be Powershell, Python, VBA, anything - as long as I can parse the subject and body of the email, I can then alter the database of my web application through this script and pick up changes with an automated task, but I really have no clue where to start. I would be really grateful if someone could point me in the right direction.
QUESTION
How can I intercept emails sent to the Outlook server and perform action based on the content of such emails?
It sounds like you need an inbound email parsing service. I've worked with the one from SendGrid and it will catch any replies to a specific email address, and then post the email contents to an action on a controller in your MVC app. This will give you access to the full email contents and you can process it as needed.
See Setting up Inbound Parse

Receive, Store, Interact with emails rails application

With my rails application, I'm supposed to provide following features:
There a limited number of users interacting with my system (in order of 10 to 20)
Like any normal mail client users should be able to have an inbox page showing received message, response to individual email and etc....
The mail client part cannot be an external application, they want everything packaged into a single application!
Normally These emails should be stored for future use
In order to send a receive email, we do not need to setup a mail server. They will provide the server and we will fetch the message with POP3 or something else. Same goes for sending emails.
The application itself often needs to look into these message as well, so it should be able to access corresponding email objects.
Separate part of these applications can be handled with individual gems such as Mailman, ActionMailer, and etc...
But what would be your suggestions to get this done?
I suggestion customizing an open source solution according to your needs. This is a gem/project that you should look at https://github.com/mailboxer/mailboxer It has all the features that you mentioned and its straightforward in its customizations.

How to check for bounced emails in rails?

I'm currently creating an email app that is able to send emails to many users. However, I want to know whether there are bounced emails. I'm currently using Amazon SES to notify me if the email is bounced. However, I want the bounced email's data to be automatically entered into my Rails application instead of typing it manually based to the mailer daemons I get from Amazon. Is there are way to do so?
If you are willing to pay, this SaaS site called bouncely seems to provide an interface and an api wrapper around SES bounces.
send_email() returns a response object which can be interrogated for the response metadata.
Compare the status of this with the code you are interested in, perhaps a 550.
I couldn't find any clean existing solution for this, so I wrote a gem (email_events) that allows you to put a email event handler method (including for bounce events) right in your mailer class: https://github.com/85x14/email_events. It supports SES and Sendgrid, so should work for you if you still need it.

Processing all the email sent to a specific domain

Requirement:
I am writing a web application (Rails on Heroku) through which users can create groups and user should be able to post a message to the group simply by sending an email to the group.
This is what tumblr.com does: each blog is associated with an email address(randomly generated) and user can post to the blog simply by sending an email. Also posterous.com has this feature.
Question:
What is the best way to architect a solution like this one? Comments? Ideas?
I see 2 ways of doing this:
1) Hosting my own email server (sendmail or postfix) on Amazon EC2 and having some script to process all the incoming email?
This will give me a lot of control but an email server to maintain.
2) Have the email server hosted somewhere and just have to write the email processing script would be nice however I do not know of any email cloud service to which you can tell: "please accept all the email for mydomain.com".
Thanks in advance for any help.
I think I am going to go with http://cloudmailin.com. They even have a nice Heroku plug-in. It would be nice to hear any good or bad experience from somebody that tried this out.
You could have the emails sent to GMail through their SMTP servers and run some sort of crontab to pull down the emails from GMail, and process them from there.
They do allow you to have emails sent to your domain.com, see this page:
http://www.google.com/apps/intl/en/group/index.html

handle bounced email - ActionMailer

I have a rails app and I am using ActionMailer to send email but now I need to know if the email is delivered or what?
Do anyone has an idea of how to handle sent emails status(e.g bounced, delivered) ?
thanks.
Email service providers use a technique called variable envelope return path. The idea is to encode a unique key for each message into the (envelope) return address so that when a destination smtp server returns email as a bounce you can tie it to the originating message.
If it sounds complex, it is. It gets harder if you want to track response rates, which links were clicked, opens, use Domain Keys, etc. Note that it requires you to set up or configure an SMTP server for handling returned mail.
There are a number of services that provide this all to you on a Software As Service basis. We use socketlabs and are very happy with them. Industrial strength and all. I've also heard of people using Postmark in the Ruby community.

Resources