summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-30 03:38:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-30 03:38:26 +0000
commit2d8228c28e3604ff5ec533eaf73e81c349b15bf1 (patch)
treea5cc135a4309a47ff15e2c60a6276815538986df /lib
parent6d56e80ad1bce411b1d4fe425e2842768a3bcfa6 (diff)
* lib/net/imap.rb (example): support starttls option.
[ruby-dev:41888] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/net/imap.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 3404700297..fded6cc152 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -3471,15 +3471,17 @@ if __FILE__ == $0
$user = ENV["USER"] || ENV["LOGNAME"]
$auth = "login"
$ssl = false
+ $starttls = false
def usage
- $stderr.print <<EOF
+ <<EOF
usage: #{$0} [options] <host>
--help print this message
--port=PORT specifies port
--user=USER specifies user
--auth=AUTH specifies auth type
+ --starttls use starttls
--ssl use ssl
EOF
end
@@ -3510,6 +3512,7 @@ EOF
['--port', GetoptLong::REQUIRED_ARGUMENT],
['--user', GetoptLong::REQUIRED_ARGUMENT],
['--auth', GetoptLong::REQUIRED_ARGUMENT],
+ ['--starttls', GetoptLong::NO_ARGUMENT],
['--ssl', GetoptLong::NO_ARGUMENT])
begin
parser.each_option do |name, arg|
@@ -3522,26 +3525,27 @@ EOF
$auth = arg
when "--ssl"
$ssl = true
+ when "--starttls"
+ $starttls = true
when "--debug"
Net::IMAP.debug = true
when "--help"
usage
- exit(1)
+ exit
end
end
rescue
- usage
- exit(1)
+ abort usage
end
$host = ARGV.shift
unless $host
- usage
- exit(1)
+ abort usage
end
imap = Net::IMAP.new($host, :port => $port, :ssl => $ssl)
begin
+ imap.starttls if $starttls
password = get_password
imap.authenticate($auth, $user, password)
while true