Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add :ssl and :use_login options to support Google's IMAP

  • Loading branch information...
commit e4540b9b5fa77237f78e75e21d059dde8a774ab6 1 parent 9c5026f
@look authored
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/fetcher/imap.rb
View
12 lib/fetcher/imap.rb
@@ -10,16 +10,24 @@ class Imap < Base
# Additional Options:
# * <tt>:authentication</tt> - authentication type to use, defaults to PLAIN
# * <tt>:port</tt> - port to use (defaults to 143)
+ # * <tt>:ssl</tt> - use SSL to connect
+ # * <tt>:use_login</tt> - use LOGIN instead of AUTHENTICATE to connect (some IMAP servers, like GMail, do not support AUTHENTICATE)
def initialize(options={})
@authentication = options.delete(:authentication) || 'PLAIN'
@port = options.delete(:port) || PORT
+ @ssl = options.delete(:ssl)
+ @use_login = options.delete(:use_login)
super(options)
end
# Open connection and login to server
def establish_connection
- @connection = Net::IMAP.new(@server, @port)
- @connection.authenticate(@authentication, @username, @password)
+ @connection = Net::IMAP.new(@server, @port, @ssl)
+ if @use_login
+ @connection.login(@username, @password)
+ else
+ @connection.authenticate(@authentication, @username, @password)
+ end
end
# Retrieve messages from server
Please sign in to comment.
Something went wrong with that request. Please try again.