Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.