8

I am developing an application where users add their Gmail accounts, and I do some classification work on their emails.

I want to be notified when a new email comes to any of the registered accounts.

A solution is to keep polling the accounts via IMAP and saving the last email date I have fetched to check whether there is a new mail or not, but this has a lot of overhead.

Any idea how to monitor Gmail and be notified when a new email is received and integrate this with a Rails app? Is there an extension which can do that and send a post request to my Rails application for example?

David J.
  • 31,569
  • 22
  • 122
  • 174
Shakes
  • 179
  • 1
  • 9
  • Possible duplicate question: http://stackoverflow.com/questions/9040344/how-to-receive-push-notification-from-my-gmail-account – Digitalex May 23 '12 at 12:01
  • yes , but the other question did not reach a solution too – Shakes May 23 '12 at 16:16
  • I think @Shakes is seeking a Rails-specific tool for Gmail push notifications, so this question is significantly different from http://stackoverflow.com/questions/9040344/how-to-receive-push-notification-from-my-gmail-account – David J. Jun 21 '12 at 03:41
  • @Shakes To answer this style of question ("are there gems for X?"), it is very useful to search http://rubygems.org and http://ruby-toolbox.com. My answer below involved searching for "IMAP" and "Gmail" and weeding out some old, inactive projects. – David J. Jun 21 '12 at 03:51

2 Answers2

1

I'm pretty sure IMAP is the only answer here.

You may want to see whether IDLE works--I've read conflicting answers. If it does, it's way more responsive than polling.

Otherwise, poll away.

Wikipedia article on IDLE

David
  • 1,143
  • 8
  • 12
  • is there any ruby implementation for imap idle ? i saw conflicting answers for net/imap too. it would be great if there is a gem which implements this feature – Shakes May 23 '12 at 16:29
1

Try these:

  1. If you want low-level, Ruby provides Net::IMAP.

  2. You can try the imap_processor gem.

  3. You can try the gmail gem.

Dig into them and let us know what works for you, particularly with regards to IDLE.

David J.
  • 31,569
  • 22
  • 122
  • 174