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_ =

require 'net/imap'

if !ARGV[4]
puts "USAGE: ruby imapcheck.rb [server] [username] [password] [folder] [flag]"

##### Variable Section
## your imap mail server
## your imap/smtp mail username
## your imap/smtp mail password
## your mail folder (for example, INBOX)
## flag to use (as per RFC 2060)
##### End Variable Section

imap =$SERVER)
count = imap.status($FOLDER,[$FLAG])[$FLAG]

puts "#{count} messages with flag #{$FLAG} \n\n"
total_time = - 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.

Share this on Social networks
TwitterFacebookLinkedInPin ItWhatsApp

On this website we use first or third-party tools that store small files (cookie) on your device. Cookies are normally used to allow the site to run properly (technical cookies), to generate navigation usage reports (statistics cookies) and to suitable advertise our services/products (profiling cookies). We can directly use technical cookies, but you have the right to choose whether or not to enable statistical and profiling cookies. Enabling these cookies, you help us to offer you a better experience. Cookie and Privacy policy