def initialize uri, username, password, last_uid=nil, usual=true, archived=false, id=nil
raise ArgumentError, "username and password must be specified" unless username && password
+ raise ArgumentError, "not an imap uri" unless uri =~ %r!imaps?://!
super uri, last_uid, usual, archived, id
@password = password
@imap = nil
@labels = [:unread]
- @labels << mailbox.intern unless mailbox =~ /inbox/i || mailbox.nil?
@labels << :inbox unless archived?
+ @labels << mailbox.intern unless mailbox =~ /inbox/i || mailbox.nil?
connect
end
::Thread.new do
begin
#raise Net::IMAP::ByeResponseError, "simulated imap failure"
- @imap = Net::IMAP.new @parsed_uri.host, ssl? ? 993 : 143, ssl?
+ @imap = Net::IMAP.new host, ssl? ? 993 : 143, ssl?
@imap.authenticate 'LOGIN', @username, @password
@imap.examine mailbox
Redwood::log "successfully connected to #{@parsed_uri}, mailbox #{mailbox}"
end
private :connect
+ def host; @parsed_uri.host; end
def mailbox; @parsed_uri.path[1..-1] end ##XXXX TODO handle nil
def ssl?; @parsed_uri.scheme == 'imaps' end