net/imap idle

P

Payton Swick

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)
put_string(CRLF)
end
end
def done
cmd = "DONE"
synchronize do
put_string(cmd)
put_string(CRLF)
end
end
end

-Payton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top