Added plain auth methode.
This commit is contained in:
parent
d6869344fb
commit
2fcfba1bb6
1 changed files with 19 additions and 3 deletions
|
@ -4,10 +4,26 @@ class Channel::IMAP < Channel::EmailParser
|
||||||
include UserInfo
|
include UserInfo
|
||||||
|
|
||||||
def fetch (channel)
|
def fetch (channel)
|
||||||
puts "fetching imap (#{channel[:options][:host]}/#{channel[:options][:user]})"
|
ssl = false
|
||||||
|
port = 143
|
||||||
|
if channel[:options][:ssl].to_s == 'true'
|
||||||
|
ssl = true
|
||||||
|
port = 993
|
||||||
|
end
|
||||||
|
|
||||||
imap = Net::IMAP.new(channel[:options][:host], 993, true, nil, false )
|
puts "fetching imap (#{channel[:options][:host]}/#{channel[:options][:user]} port=#{port},ssl=#{ssl})"
|
||||||
|
|
||||||
|
imap = Net::IMAP.new( channel[:options][:host], port, ssl, nil, false )
|
||||||
|
|
||||||
|
# try LOGIN, if not - try plain
|
||||||
|
begin
|
||||||
imap.authenticate( 'LOGIN', channel[:options][:user], channel[:options][:password] )
|
imap.authenticate( 'LOGIN', channel[:options][:user], channel[:options][:password] )
|
||||||
|
rescue Exception => e
|
||||||
|
if e.to_s !~ /unsupported\sauthentication\smechanism/i
|
||||||
|
raise e
|
||||||
|
end
|
||||||
|
imap.login( channel[:options][:user], channel[:options][:password] )
|
||||||
|
end
|
||||||
imap.select('INBOX')
|
imap.select('INBOX')
|
||||||
count = 0
|
count = 0
|
||||||
count_all = imap.search(['ALL']).count
|
count_all = imap.search(['ALL']).count
|
||||||
|
|
Loading…
Reference in a new issue