Skip to content

Instantly share code, notes, and snippets.

@kou1okada
Created February 7, 2014 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kou1okada/8862432 to your computer and use it in GitHub Desktop.
Save kou1okada/8862432 to your computer and use it in GitHub Desktop.
check the PERMANENTFLAGS of a IMAP server.
#!/usr/bin/env ruby
require 'rubygems'
require 'highline'
require 'net/imap'
require 'optparse'
$config = {}
$config[:ssl] = true
opts = OptionParser.new
opts.on("-h", "--host HOST" ){|v| $config[:host] = v }
opts.on("-p", "--port PORT" , Integer ){|v| $config[:port] = v }
opts.on("-u", "--user USER" ){|v| $config[:user] = v }
opts.on( "--nossl" ){|v| $config[:ssl] = false}
begin
opts.parse!(ARGV)
rescue OptionParser::ParseError => err
print opts.help
print "\nerror: " + err + "\n"
exit
end
$config[:port] = $config[:ssl] ? 993 : 143 if $config[:port].nil?
$config[:host] = HighLine.new.ask("Host: ") if $config[:host].nil?
$config[:user] = HighLine.new.ask("User: ") if $config[:user].nil?
$config[:pass] = HighLine.new.ask("Pass: ") {|q| q.echo = '*'} if $config[:pass].nil?
imap = Net::IMAP.new($config[:host], $config[:port], $config[:ssl])
imap.login($config[:user], $config[:pass])
imap.select("INBOX")
p imap.responses["PERMANENTFLAGS"]
imap.disconnect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment