More on Ruby and IMAP
I've written here of a Ruby IMAP Script.
The script is INCREDIBLY simple (but it had to do a simple thing nonethless):
#!/usr/bin/env ruby
begin_ = Time.now
require 'net/imap'
if !ARGV[4]
puts "USAGE: ruby imapcheck.rb [server] [username] [password] [folder] [flag]"
exit
end
##### Variable Section
## your imap mail server
$SERVER=ARGV[0]
## your imap/smtp mail username
$USERNAME=ARGV[1]
## your imap/smtp mail password
$PASSWORD=ARGV[2]
## your mail folder (for example, INBOX)
$FOLDER=ARGV[3]
## flag to use (as per RFC 2060)
$FLAG=ARGV[4]
##### End Variable Section
imap = Net::IMAP.new($SERVER)
imap.login($USERNAME, $PASSWORD)
imap.select($FOLDER)
count = imap.status($FOLDER,[$FLAG])[$FLAG]
puts "#{count} messages with flag #{$FLAG} \n\n"
total_time = Time.now - begin_
puts "RUNTIME: #{total_time}"
There is another interesting example about this at Will's Blog. It's funny how people try to do the same things at similar times
Of course official doc for this is here.
But If you want to snoop at a more complex webmail application using IMAP from Ruby/Rails you should seriously check out Mailr.
Related posts:
- Backup or Store stuff to GMail via IMAP in Ruby
- Java… oh Java… (aka "High vs. Low level languages rant")
- MX records and small servers
- Thoughts, Blogs, and Ruby with .Net
- Google has pissed me off this week!
Related posts brought to you by Yet Another Related Posts Plugin.