Processing all the email sent to a specific domain - ruby-on-rails

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

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

mailbox always empty when checking emails via imap

Our platform is regularly checking some of our clients mailbox looking for answered emails, so far it's been working perfectly but we recently got a client with a strange issue.
When i connect to the IMAP server and search for email on a given period of time (for instance all mails from yesterday), i just get an empty list. But when i check with the client on its mailbox i can see the mail received from yesterday. Her mail client was configured to use POP so i asked her to change to IMAP as POP is supposed to remove email from the mail server. Now she is using IMAP but i still can not see anything on the mail server.
To connect to the IMAP server i am using those instructions:
imap = Net::IMAP.new(server, port, ssl, nil, false) # OK
imap.login(login, pwd) # Authentification Successful
imap.select("INBOX") # Mailbox is OK
To look for email from yesterday i am using those criteria:
imap.search(["SEEN","SINCE","Sep-07-2015"]
imap.search(["SEEN","SINCE","Sep-07-2015"]
I even tried to look into other mailbox in case her mail didn't arrive on Inbox, i have listed her mailboxes with imap.list('', '') even so i can not find any mails. It feels her entire mailbox is empty on the server. Yet i can see her emails on the mail client.
I am at loss on this case and was wondering if anyone has an idea of what could be happening preventing me from discovering any emails via IMAP?
It seems you have incorrect date format: it should be similar to 8-Aug-2002 and not Aug-8-2002. Look here for other options. If that doesn't help, try some easier search with a more broader criteria, something like imap.search(['SUBJECT', 'hello']) and use instead of hello some real subject.
This article also may help.
Cheers!
you can use this syntaxe in php , example for yahoo
$inbox='{imap.mail.yahoo.com:993/imap/ssl/novalidate-cert}Inbox';
$mbox = imap_open($inbox,$username,$password);
imap_search($mbox, 'SINCE "'.date('d M Y',strtotime("-1 days")).'"');

Rails 3 - Incoming Mail Ingest via email

I want to have a stable way to allow users to email posts to my app. I've been trying CloudMailin but need something more reliable and high performance / fast to respond.
Any Rails 3 - heroku solutions out there that can handle Incoming Email Ingest?
thank you
SendGrid is another option. Here's the page from the documentation about parsing incoming e-mail.
Hi I can only apologise if you have been having issues with CloudMailin. Perhaps we could try and rectify the issues you have been experiencing. Contact us via email and we can look into things. Emails should be arriving within milliseconds of sending. If they are not then there is something going on.

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

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.

reaching Gmail SMTP daily limit

In one of my Rails applications I'm sending emails through the Gmail SMTP server and everything just works, mails are not going to spam and so on ... But there's one thing that concerns me, the 500messages/day limit the SMTP has, currently I'm over 350/day. I didn't find any official Google page where they talk about the subject, just blog posts that seems to be reliable. Then my question is what do you suggest me in order to be able to send more than 500messages/day? I would love to keep using the Gmail SMTP.
Any help would be appreciated.
Don't use GMail for what it wasn't built for. It wasn't designed as a mass-email system, although Google definitely has the firepower to do this.
Instead, perhaps use something like SendGrid to send your emails. SendGrid is designed for this and is just as easy (actually, probably easier) to set up with than GMail.
You can consider using more than one gmail account to access the smtp server, however you may have problems with ip limits (couldn't find anything on their docs about it). Another option is performing dns mx lookups yourself and reproducing your own smtp server by directly delivering the messages to the user's emails - but that can increase the odds of you being tagged as a spammer as your ip is not whitelisted as sender.
I think the best way is to create another gmail account and trying to reroute your connection to use it when one of the accounts reaches the daily limit. A vpn connection can solve that for you.

Resources