Added hotmail/outlook support for probing.

This commit is contained in:
Martin Edenhofer 2014-12-11 11:44:23 +01:00
parent acafc33800
commit a00410758a
4 changed files with 127 additions and 92 deletions

View file

@ -169,11 +169,34 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
:outbound => { :outbound => {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => 'smtp.gmail.com', :host => 'smtp.gmail.com',
:port => '25', :port => '25',
:start_tls => true,
:user => params[:email],
:password => params[:password],
}
},
},
:microsoft => {
:domain => 'outlook.com|hotmail.com',
:inbound => {
:adapter => 'imap',
:options => {
:host => 'imap-mail.outlook.com',
:port => '993',
:ssl => true, :ssl => true,
:user => params[:email], :user => params[:email],
:password => params[:password], :password => params[:password],
},
},
:outbound => {
:adapter => 'smtp',
:options => {
:host => 'smtp-mail.outlook.com',
:port => 25,
:start_tls => true,
:user => params[:email],
:password => params[:password],
} }
}, },
}, },
@ -372,41 +395,41 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
{ {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => mail_exchangers[0][0], :host => mail_exchangers[0][0],
:port => 25, :port => 25,
:ssl => true, :start_tls => true,
:user => user, :user => user,
:password => params[:password], :password => params[:password],
}, },
}, },
{ {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => mail_exchangers[0][0], :host => mail_exchangers[0][0],
:port => 25, :port => 25,
:ssl => true, :start_tls => true,
:user => params[:email], :user => params[:email],
:password => params[:password], :password => params[:password],
}, },
}, },
{ {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => mail_exchangers[0][0], :host => mail_exchangers[0][0],
:port => 465, :port => 465,
:ssl => true, :start_tls => true,
:user => user, :user => user,
:password => params[:password], :password => params[:password],
}, },
}, },
{ {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => mail_exchangers[0][0], :host => mail_exchangers[0][0],
:port => 465, :port => 465,
:ssl => true, :start_tls => true,
:user => params[:email], :user => params[:email],
:password => params[:password], :password => params[:password],
}, },
}, },
] ]
@ -416,81 +439,81 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
{ {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => "mail.#{domain}", :host => "mail.#{domain}",
:port => 25, :port => 25,
:ssl => true, :start_tls => true,
:user => user, :user => user,
:password => params[:password], :password => params[:password],
}, },
}, },
{ {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => "mail.#{domain}", :host => "mail.#{domain}",
:port => 25, :port => 25,
:ssl => true, :start_tls => true,
:user => params[:email], :user => params[:email],
:password => params[:password], :password => params[:password],
}, },
}, },
{ {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => "mail.#{domain}", :host => "mail.#{domain}",
:port => 465, :port => 465,
:ssl => true, :start_tls => true,
:user => user, :user => user,
:password => params[:password], :password => params[:password],
}, },
}, },
{ {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => "mail.#{domain}", :host => "mail.#{domain}",
:port => 465, :port => 465,
:ssl => true, :start_tls => true,
:user => params[:email], :user => params[:email],
:password => params[:password], :password => params[:password],
}, },
}, },
{ {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => "smtp.#{domain}", :host => "smtp.#{domain}",
:port => 25, :port => 25,
:ssl => true, :start_tls => true,
:user => user, :user => user,
:password => params[:password], :password => params[:password],
}, },
}, },
{ {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => "smtp.#{domain}", :host => "smtp.#{domain}",
:port => 25, :port => 25,
:ssl => true, :start_tls => true,
:user => params[:email], :user => params[:email],
:password => params[:password], :password => params[:password],
}, },
}, },
{ {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => "smtp.#{domain}", :host => "smtp.#{domain}",
:port => 465, :port => 465,
:ssl => true, :start_tls => true,
:user => user, :user => user,
:password => params[:password], :password => params[:password],
}, },
}, },
{ {
:adapter => 'smtp', :adapter => 'smtp',
:options => { :options => {
:host => "smtp.#{domain}", :host => "smtp.#{domain}",
:port => 465, :port => 465,
:ssl => true, :start_tls => true,
:user => params[:email], :user => params[:email],
:password => params[:password], :password => params[:password],
}, },
}, },
] ]

View file

@ -17,7 +17,7 @@ class Channel::IMAP < Channel::EmailParser
# on check, reduce open_timeout to have faster probing # on check, reduce open_timeout to have faster probing
timeout = 12 timeout = 12
if check_type == 'check' if check_type == 'check'
timeout = 4 timeout = 6
end end
Timeout.timeout(timeout) do Timeout.timeout(timeout) do
@ -30,7 +30,7 @@ class Channel::IMAP < Channel::EmailParser
begin begin
@imap.authenticate( 'LOGIN', channel[:options][:user], channel[:options][:password] ) @imap.authenticate( 'LOGIN', channel[:options][:user], channel[:options][:password] )
rescue Exception => e rescue Exception => e
if e.to_s !~ /unsupported\s(authenticate|authentication)\smechanism/i if e.to_s !~ /(unsupported\s(authenticate|authentication)\smechanism|not\ssupported)/i
raise e raise e
end end
@imap.login( channel[:options][:user], channel[:options][:password] ) @imap.login( channel[:options][:user], channel[:options][:password] )

View file

@ -14,8 +14,7 @@ class Channel::SMTP < Channel::EmailBuild
:domain => channel[:options][:host], :domain => channel[:options][:host],
:user_name => channel[:options][:user], :user_name => channel[:options][:user],
:password => channel[:options][:password], :password => channel[:options][:password],
# :authentication => 'plain', :enable_starttls_auto => true,
:enable_starttls_auto => true
} }
mail.deliver mail.deliver
end end

View file

@ -3,8 +3,11 @@ require 'browser_test_helper'
class AaaGettingStartedTest < TestCase class AaaGettingStartedTest < TestCase
def test_a_getting_started def test_a_getting_started
#return # TODO: temp disable
if !ENV['MAILBOX_INIT'] if !ENV['MAILBOX_INIT']
raise "Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@znuny.com:somepass'" #raise "Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@znuny.com:somepass'"
puts "NOTICE: Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@znuny.com:somepass'"
return
end end
mailbox_user = ENV['MAILBOX_INIT'].split(':')[0] mailbox_user = ENV['MAILBOX_INIT'].split(':')[0]
mailbox_password = ENV['MAILBOX_INIT'].split(':')[1] mailbox_password = ENV['MAILBOX_INIT'].split(':')[1]
@ -234,19 +237,24 @@ class AaaGettingStartedTest < TestCase
end end
def test_b_accounts_auto def test_b_accounts_auto
return # TODO: temp disable #return # TODO: temp disable
if !ENV['MAILBOX_AUTO1'] accounts = []
raise "Need MAILBOX_AUTO1 as ENV variable like export MAILBOX_AUTO1='nicole.braun2015@gmail.com:somepass'" (1..10).each {|count|
end next if !ENV["MAILBOX_AUTO#{count.to_s}"]
mailbox_user = ENV['MAILBOX_AUTO1'].split(':')[0] mailbox_user = ENV["MAILBOX_AUTO#{count.to_s}"].split(':')[0]
mailbox_password = ENV['MAILBOX_AUTO1'].split(':')[1] mailbox_password = ENV["MAILBOX_AUTO#{count.to_s}"].split(':')[1]
accounts = [ account = {
{ :realname => 'auto account',
:realname => 'gmail',
:email => mailbox_user, :email => mailbox_user,
:password => mailbox_password, :password => mailbox_password,
}, }
] accounts.push account
}
if accounts.empty?
#raise "Need min. MAILBOX_AUTO1 as ENV variable like export MAILBOX_AUTO1='nicole.braun2015@gmail.com:somepass'"
puts "NOTICE: Need min. MAILBOX_AUTO1 as ENV variable like export MAILBOX_AUTO1='nicole.braun2015@gmail.com:somepass'"
return
end
accounts.each {|account| accounts.each {|account|
tests = [ tests = [
{ {
@ -303,18 +311,16 @@ class AaaGettingStartedTest < TestCase
end end
def test_b_accounts_manual def test_b_accounts_manual
return # TODO: temp disable #return # TODO: temp disable
if !ENV['MAILBOX_MANUAL1'] accounts = []
raise "Need MAILBOX_AUTO1 as ENV variable like export MAILBOX_MANUAL1='nicole.bauer2015@yahoo.de:somepass:imap.mail.yahoo.com:smtp.mail.yahoo.com'" (1..10).each {|count|
end next if !ENV["MAILBOX_MANUAL#{count.to_s}"]
mailbox_user = ENV['MAILBOX_MANUAL1'].split(':')[0] mailbox_user = ENV["MAILBOX_MANUAL#{count.to_s}"].split(':')[0]
mailbox_password = ENV['MAILBOX_MANUAL1'].split(':')[1] mailbox_password = ENV["MAILBOX_MANUAL#{count.to_s}"].split(':')[1]
mailbox_inbound = ENV['MAILBOX_MANUAL1'].split(':')[2] mailbox_inbound = ENV["MAILBOX_MANUAL#{count.to_s}"].split(':')[2]
mailbox_outbound = ENV['MAILBOX_MANUAL1'].split(':')[3] mailbox_outbound = ENV["MAILBOX_MANUAL#{count.to_s}"].split(':')[3]
account = {
accounts = [ :realname => 'manual account',
{
:realname => 'yahoo',
:email => mailbox_user, :email => mailbox_user,
:password => mailbox_password, :password => mailbox_password,
:inbound => { :inbound => {
@ -323,8 +329,15 @@ class AaaGettingStartedTest < TestCase
:outbound => { :outbound => {
'options::host' => mailbox_outbound, 'options::host' => mailbox_outbound,
}, },
}, }
] accounts.push account
}
if accounts.empty?
#raise "Need min. MAILBOX_MANUAL1 as ENV variable like export MAILBOX_MANUAL1='nicole.bauer2015@yahoo.de:somepass:imap.mail.yahoo.com:smtp.mail.yahoo.com'"
puts "NOTICE: Need min. MAILBOX_MANUAL1 as ENV variable like export MAILBOX_MANUAL1='nicole.bauer2015@yahoo.de:somepass:imap.mail.yahoo.com:smtp.mail.yahoo.com'"
return
end
accounts.each {|account| accounts.each {|account|
tests = [ tests = [
{ {