diff --git a/lib/email_helper.rb b/lib/email_helper.rb index b0de52a7c..dc05a2906 100644 --- a/lib/email_helper.rb +++ b/lib/email_helper.rb @@ -1,4 +1,4 @@ -module EmailHelper +class EmailHelper =begin @@ -454,6 +454,24 @@ returns password: password, }, }, + { + adapter: 'smtp', + options: { + host: domain, + port: 587, + user: user, + password: password, + }, + }, + { + adapter: 'smtp', + options: { + host: domain, + port: 587, + user: email, + password: password, + }, + }, ] outbounds = outbounds.concat(outbound) end diff --git a/lib/email_helper/probe.rb b/lib/email_helper/probe.rb index bab4ed198..ff99346f5 100644 --- a/lib/email_helper/probe.rb +++ b/lib/email_helper/probe.rb @@ -1,4 +1,4 @@ -module EmailHelper +class EmailHelper class Probe =begin @@ -400,6 +400,7 @@ returns on fail 'Incorrect username' => 'Authentication failed, username incorrect!', 'Lookup failed' => 'Authentication failed, username incorrect!', 'Invalid credentials' => 'Authentication failed, invalid credentials!', + 'authentication not enabled' => 'Authentication not possible (not offered by the service)', 'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!', 'getaddrinfo: Name or service not known' => 'Hostname not found!', 'No route to host' => 'No route to host!', diff --git a/lib/email_helper/verify.rb b/lib/email_helper/verify.rb index 517614b48..db28ca11c 100644 --- a/lib/email_helper/verify.rb +++ b/lib/email_helper/verify.rb @@ -1,4 +1,4 @@ -module EmailHelper +class EmailHelper class Verify =begin diff --git a/test/integration/email_helper_test.rb b/test/integration/email_helper_test.rb index 4750b671f..9493c2ac6 100644 --- a/test/integration/email_helper_test.rb +++ b/test/integration/email_helper_test.rb @@ -4,9 +4,9 @@ class EmailHelperTest < ActiveSupport::TestCase test 'a mx_records' do - domain = 'znuny.com' + domain = 'zammad.com' mx_domains = EmailHelper.mx_records(domain) - assert_equal('arber.znuny.com', mx_domains[0]) + assert_equal('mx2.zammad.com', mx_domains[0]) end @@ -48,20 +48,20 @@ class EmailHelperTest < ActiveSupport::TestCase test 'provider_inbound_mx' do - email = 'linus@znuny.com' + email = 'linus@zammad.com' password = 'some_pw' user, domain = EmailHelper.parse_email(email) mx_domains = EmailHelper.mx_records(domain) map = EmailHelper.provider_inbound_mx(user, email, password, mx_domains) assert_equal('imap', map[0][:adapter]) - assert_equal('arber.znuny.com', map[0][:options][:host]) + assert_equal('mx2.zammad.com', map[0][:options][:host]) assert_equal(993, map[0][:options][:port]) assert_equal(user, map[0][:options][:user]) assert_equal(password, map[0][:options][:password]) assert_equal('imap', map[1][:adapter]) - assert_equal('arber.znuny.com', map[1][:options][:host]) + assert_equal('mx2.zammad.com', map[1][:options][:host]) assert_equal(993, map[1][:options][:port]) assert_equal(email, map[1][:options][:user]) assert_equal(password, map[1][:options][:password]) @@ -70,19 +70,19 @@ class EmailHelperTest < ActiveSupport::TestCase test 'provider_inbound_guess' do - email = 'linus@znuny.com' + email = 'linus@zammad.com' password = 'some_pw' user, domain = EmailHelper.parse_email(email) map = EmailHelper.provider_inbound_guess(user, email, password, domain) assert_equal('imap', map[0][:adapter]) - assert_equal('mail.znuny.com', map[0][:options][:host]) + assert_equal('mail.zammad.com', map[0][:options][:host]) assert_equal(993, map[0][:options][:port]) assert_equal(user, map[0][:options][:user]) assert_equal(password, map[0][:options][:password]) assert_equal('imap', map[1][:adapter]) - assert_equal('mail.znuny.com', map[1][:options][:host]) + assert_equal('mail.zammad.com', map[1][:options][:host]) assert_equal(993, map[1][:options][:port]) assert_equal(email, map[1][:options][:user]) assert_equal(password, map[1][:options][:password]) @@ -91,21 +91,21 @@ class EmailHelperTest < ActiveSupport::TestCase test 'provider_outbound_mx' do - email = 'linus@znuny.com' + email = 'linus@zammad.com' password = 'some_pw' user, domain = EmailHelper.parse_email(email) mx_domains = EmailHelper.mx_records(domain) map = EmailHelper.provider_outbound_mx(user, email, password, mx_domains) assert_equal('smtp', map[0][:adapter]) - assert_equal('arber.znuny.com', map[0][:options][:host]) + assert_equal('mx2.zammad.com', map[0][:options][:host]) assert_equal(25, map[0][:options][:port]) assert_equal(true, map[0][:options][:start_tls]) assert_equal(user, map[0][:options][:user]) assert_equal(password, map[0][:options][:password]) assert_equal('smtp', map[1][:adapter]) - assert_equal('arber.znuny.com', map[1][:options][:host]) + assert_equal('mx2.zammad.com', map[1][:options][:host]) assert_equal(25, map[1][:options][:port]) assert_equal(true, map[1][:options][:start_tls]) assert_equal(email, map[1][:options][:user]) @@ -115,20 +115,20 @@ class EmailHelperTest < ActiveSupport::TestCase test 'provider_outbound_guess' do - email = 'linus@znuny.com' + email = 'linus@zammad.com' password = 'some_pw' user, domain = EmailHelper.parse_email(email) map = EmailHelper.provider_outbound_guess(user, email, password, domain) assert_equal('smtp', map[0][:adapter]) - assert_equal('mail.znuny.com', map[0][:options][:host]) + assert_equal('mail.zammad.com', map[0][:options][:host]) assert_equal(25, map[0][:options][:port]) assert_equal(true, map[0][:options][:start_tls]) assert_equal(user, map[0][:options][:user]) assert_equal(password, map[0][:options][:password]) assert_equal('smtp', map[1][:adapter]) - assert_equal('mail.znuny.com', map[1][:options][:host]) + assert_equal('mail.zammad.com', map[1][:options][:host]) assert_equal(25, map[1][:options][:port]) assert_equal(true, map[1][:options][:start_tls]) assert_equal(email, map[1][:options][:user]) @@ -236,7 +236,7 @@ class EmailHelperTest < ActiveSupport::TestCase result = EmailHelper::Probe.inbound( adapter: 'imap', options: { - host: 'arber.znuny.com', + host: 'mx2.zammad.com', port: 993, ssl: true, user: 'some@example.com', @@ -245,23 +245,22 @@ class EmailHelperTest < ActiveSupport::TestCase ) assert_equal('invalid', result[:result]) assert_equal('Authentication failed!', result[:message_human]) - assert_equal('arber.znuny.com', result[:settings][:options][:host]) + assert_equal('mx2.zammad.com', result[:settings][:options][:host]) # realtest - test I if !ENV['EMAILHELPER_MAILBOX_1'] - raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'" + raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@zammad.com:somepass'" end mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0] mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1] - user, _domain = EmailHelper.parse_email(mailbox_user) result = EmailHelper::Probe.inbound( adapter: 'imap', options: { - host: 'arber.znuny.com', + host: 'mx2.zammad.com', port: 993, ssl: true, - user: user, + user: mailbox_user, password: mailbox_password, } ) @@ -388,36 +387,33 @@ class EmailHelperTest < ActiveSupport::TestCase { adapter: 'smtp', options: { - host: 'arber.znuny.com', - port: 25, - start_tls: true, - user: 'some@example.com', - password: 'password', + host: 'mx2.zammad.com', + port: 587, + user: 'some@example.com', + password: 'password', } }, 'some@example.com', ) assert_equal('invalid', result[:result]) assert_equal('Authentication failed!', result[:message_human]) - assert_equal('arber.znuny.com', result[:settings][:options][:host]) + assert_equal('mx2.zammad.com', result[:settings][:options][:host]) # realtest - test I if !ENV['EMAILHELPER_MAILBOX_1'] - raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'" + raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@zammad.com:somepass'" end mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0] mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1] - user, _domain = EmailHelper.parse_email(mailbox_user) result = EmailHelper::Probe.outbound( { adapter: 'smtp', options: { - host: 'arber.znuny.com', - port: 25, - start_tls: true, - user: user, - password: mailbox_password, + host: 'mx2.zammad.com', + port: 587, + user: mailbox_user, + password: mailbox_password, } }, mailbox_user, @@ -436,7 +432,7 @@ class EmailHelperTest < ActiveSupport::TestCase # realtest - test I, with imap if !ENV['EMAILHELPER_MAILBOX_1'] - raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'" + raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@zammad.com:somepass'" end mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0] @@ -447,8 +443,8 @@ class EmailHelperTest < ActiveSupport::TestCase password: mailbox_password, ) assert_equal('ok', result[:result]) - assert_equal('arber.znuny.com', result[:setting][:inbound][:options][:host]) - assert_equal('arber.znuny.com', result[:setting][:outbound][:options][:host]) + assert_equal('mx2.zammad.com', result[:setting][:inbound][:options][:host]) + assert_equal('mx2.zammad.com', result[:setting][:outbound][:options][:host]) # realtest - test II, gmail with only pop3 if !ENV['EMAILHELPER_MAILBOX_2'] @@ -473,31 +469,29 @@ class EmailHelperTest < ActiveSupport::TestCase # realtest - test I, with imap if !ENV['EMAILHELPER_MAILBOX_1'] - raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@znuny.com:somepass'" + raise "Need EMAILHELPER_MAILBOX_1 as ENV variable like export EMAILHELPER_MAILBOX_1='unittestemailhelper01@zammad.com:somepass'" end mailbox_user = ENV['EMAILHELPER_MAILBOX_1'].split(':')[0] mailbox_password = ENV['EMAILHELPER_MAILBOX_1'].split(':')[1] - user, _domain = EmailHelper.parse_email(mailbox_user) result = EmailHelper::Verify.email( inbound: { adapter: 'imap', options: { - host: 'arber.znuny.com', + host: 'mx2.zammad.com', port: 993, ssl: true, - user: user, + user: mailbox_user, password: mailbox_password, }, }, outbound: { adapter: 'smtp', options: { - host: 'arber.znuny.com', - port: 25, - start_tls: true, - user: user, - password: mailbox_password, + host: 'mx2.zammad.com', + port: 587, + user: mailbox_user, + password: mailbox_password, }, }, sender: mailbox_user,