Skip to content

Instantly share code, notes, and snippets.

@neilmock
Created February 6, 2009 22:28
Show Gist options
  • Save neilmock/59659 to your computer and use it in GitHub Desktop.
Save neilmock/59659 to your computer and use it in GitHub Desktop.
require 'net/imap'
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
imap = Net::IMAP.new('imap.gmail.com', '993', true)
imap.login('you@yomammashouse.com', 'slappy')
imap.select('Inbox')
imap.add_response_handler { |resp|
if resp.kind_of?(Net::IMAP::UntaggedResponse) and resp.name == "EXISTS"
puts "Mailbox now has #{resp.data} messages"
end
}
imap.idle
loop do
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment