views:

22

answers:

1

What is the best way to receive email via IMAP protocol in Rails 3?

A: 

I am not sure about best, but a simple way is to use Net::IMAP. You can write a rake task and periodically poll the mailbox for emails by using a scheduler like cron.

So your setup would look like this:

  1. A library file which servers as a wrapper for IMAP client and other related operations, like processing the emails.
  2. The rake task which when called downloads the emails and processes them using the wrapper mentioned above.
  3. The scheduler (Cron or any other of your choice. I personally always prefer cron) which periodically calls this rake task.
Swanand