Forum: Ruby net/imap idle

5224d56434a3d237408c217605df8a56?d=identicon&s=25 Payton Swick (Guest)
on 2006-01-05 20:51
(Received via mailing list)
Perhaps there's another way to do this without polling, but I added the
IMAP IDLE (and associated DONE) command to Shugo Maeda's excellent
net/imap API.

For those unaware, RFC 2177 adds the IDLE command to the IMAP
specification which allows the server to notify clients when a mailbox
has changed state (particularly when new mail has arrived).

When issued, an IDLE command requires a DONE to complete it, which
should be issued at least every 29 minutes, to prevent a timeout.

Anyway, here's the (tiny) piece of code I wrote to implement this; I
hope it's useful.  Feel free to tell me what I did wrong.

class Net::IMAP
   def idle
     cmd = "IDLE"
     synchronize do
       tag = generate_tag
       put_string(tag + " " + cmd)
   def done
     cmd = "DONE"
     synchronize do

Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.