check the PERMANENTFLAGS of a IMAP server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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