Method: IMAPClient#connect
- Defined in:
- lib/imap_client.rb
#connect(host, port, ssl, username, password, auth = nil) ⇒ Object
Connects to IMAP server host at port using ssl if ssl is true then logs in as username with password. IMAPClient will really only work with PLAIN auth on SSL sockets, sorry.
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/imap_client.rb', line 262 def connect(host, port, ssl, username, password, auth = nil) @imap = Net::IMAP.new host, port, ssl log "Connected to #{host}:#{port}" if auth.nil? then auth_caps = @imap.capability.select { |c| c =~ /^AUTH/ } raise "Couldn't find a supported auth type" if auth_caps.empty? auth = auth_caps.first.sub(/AUTH=/, '') end auth = auth.upcase log "Trying #{auth} authentication" @imap.authenticate auth, username, password log "Logged in as #{username}" end |