Browse Source

Maintenance: Refactored email helper tests to use the zammad-imap container.

Martin Gruner 2 years ago
parent
commit
d962f6d468

+ 2 - 8
.gitlab/ci/__includes__/variables.yml

@@ -6,19 +6,13 @@ variables:
   # Browser tests and variables
   RAILS_SERVE_STATIC_FILES: "true"
   TZ: "Europe/London"
-  # docker-imap-devel variables required for browser tests
+  # docker-imap-devel variables required for mail tests
   MAILNAME: "mail.test.dc.zammad.com"
-  MAILBOX_INIT: "zammad@mail.test.dc.zammad.com:zammad"
+  MAIL_SERVER: "mail"
   MAIL_ADDRESS: "zammad@mail.test.dc.zammad.com"
   MAIL_PASS: "zammad"
-  # docker-imap-devel variables required for integration tests
-  MAIL_SERVER: "mail"
-  MAIL_SERVER_ACCOUNT: "zammad@mail.test.dc.zammad.com:zammad"
-  MAIL_SERVER_EMAIL: "zammad@mail.test.dc.zammad.com"
   MAIL_ADDRESS_ASCII: "zammad-test@mail.test.dc.zammad.com"
   MAIL_PASS_ASCII: '¼¿B3È;yÚ}&J¢Q;{Bü@_£)D"5>RÌ8eoø’'
-  KEEP_ON_MAIL_SERVER: "mail"
-  KEEP_ON_MAIL_SERVER_ACCOUNT: "zammad@mail.test.dc.zammad.com:zammad"
 
   # Settings for elasticsearch, if active
   ES_INDEX: 'estest.ci'

+ 24 - 85
spec/lib/email_helper/probe_spec.rb

@@ -2,19 +2,12 @@
 
 require 'rails_helper'
 
-RSpec.describe EmailHelper::Probe, integration: true do
-  let(:expected_result_failed) do
-    {
-      result:  'failed',
-      message: message_human,
-    }
-  end
+RSpec.describe EmailHelper::Probe, integration: true, required_envs: %w[MAIL_SERVER MAIL_ADDRESS MAIL_PASS] do
+  let(:expected_result_failed)  { { result: 'failed', message: message_human, } }
+  let(:expected_result_invalid) { { result: 'invalid', message_human: message_human, } }
 
-  let(:expected_result_invalid) do
-    {
-      result:        'invalid',
-      message_human: message_human,
-    }
+  before do
+    allow(EmailHelper).to receive(:mx_records).and_return([ ENV['MAIL_SERVER'] ])
   end
 
   shared_examples 'probe tests with invalid result' do
@@ -86,29 +79,17 @@ RSpec.describe EmailHelper::Probe, integration: true do
       include_examples 'probe tests with invalid result'
     end
 
-    context 'when incorrect credentials are used' do
-      let(:host)          { 'imap.gmail.com' }
-      let(:message_human) { [ 'Authentication failed due to incorrect username.', 'Authentication failed due to incorrect credentials.' ] }
-
-      include_examples 'probe tests with invalid result'
-    end
-
     context 'when authentication fails' do
-      let(:host)          { 'mx2.zammad.com' }
+      let(:host)          { ENV['MAIL_SERVER'] }
       let(:message_human) { [ 'Authentication failed.', 'This host cannot be reached.' ] }
 
-      before do
-        stub_const('Channel::Driver::Imap::CHECK_ONLY_TIMEOUT', 1.second)
-      end
-
       include_examples 'probe tests with invalid result'
     end
 
-    context 'when doing a real test', required_envs: %w[EMAILHELPER_MAILBOX_1] do
-      let(:host)           { 'mx2.zammad.com' }
-      let(:real_user_data) { ENV['EMAILHELPER_MAILBOX_1'].split(':') }
-      let(:user)           { real_user_data.first }
-      let(:password)       { real_user_data.last }
+    context 'when doing a real test' do
+      let(:host)           { ENV['MAIL_SERVER'] }
+      let(:user)           { ENV['MAIL_ADDRESS'] }
+      let(:password)       { ENV['MAIL_PASS'] }
 
       it { is_expected.to include(result: 'ok') }
     end
@@ -170,32 +151,19 @@ RSpec.describe EmailHelper::Probe, integration: true do
       include_examples 'probe tests with invalid result'
     end
 
-    context 'when incorrect credentials are used' do
-      let(:host)          { 'smtp.gmail.com' }
-      let(:message_human) { 'Authentication failed.' }
-
-      include_examples 'probe tests with invalid result'
-    end
-
     context 'when authentication fails' do
-      let(:host)          { 'mx2.zammad.com' }
-      let(:port)          { 587 }
+      let(:host)          { ENV['MAIL_SERVER'] }
+      let(:port)          { 25 }
       let(:message_human) { 'Authentication failed.' }
 
-      before do
-        stub_const('Channel::Driver::Smtp::DEFAULT_OPEN_TIMEOUT', 5.seconds)
-        stub_const('Channel::Driver::Smtp::DEFAULT_READ_TIMEOUT', 10.seconds)
-      end
-
       include_examples 'probe tests with invalid result'
     end
 
-    context 'when doing a real test', required_envs: %w[EMAILHELPER_MAILBOX_1] do
-      let(:host)           { 'mx2.zammad.com' }
-      let(:port)           { 587 }
-      let(:real_user_data) { ENV['EMAILHELPER_MAILBOX_1'].split(':') }
-      let(:user)           { real_user_data.first }
-      let(:password)       { real_user_data.last }
+    context 'when doing a real test' do
+      let(:host)           { ENV['MAIL_SERVER'] }
+      let(:port)           { 25 }
+      let(:user)           { ENV['MAIL_ADDRESS'] }
+      let(:password)       { ENV['MAIL_PASS'] }
 
       let(:outbound_params) do
         {
@@ -204,16 +172,12 @@ RSpec.describe EmailHelper::Probe, integration: true do
             host:     host,
             port:     port,
             user:     user,
+            ssl:      false,
             password: password,
           },
         }
       end
 
-      before do
-        stub_const('Channel::Driver::Smtp::DEFAULT_OPEN_TIMEOUT', 5.seconds)
-        stub_const('Channel::Driver::Smtp::DEFAULT_READ_TIMEOUT', 10.seconds)
-      end
-
       it { is_expected.to include(result: 'ok') }
     end
   end
@@ -242,8 +206,8 @@ RSpec.describe EmailHelper::Probe, integration: true do
     end
 
     context 'when doing real tests' do
-      let(:email)    { real_user_data.first }
-      let(:password) { real_user_data.last }
+      let(:email)          { ENV['MAIL_ADDRESS'] }
+      let(:password)       { ENV['MAIL_PASS'] }
 
       shared_examples 'do real testing' do
         it 'contains all information for a successful probe' do
@@ -252,7 +216,7 @@ RSpec.describe EmailHelper::Probe, integration: true do
               setting: include(
                 inbound: include(
                   options: include(
-                    host: inbound_host
+                    host: host
                   ),
                 ),
               ),
@@ -261,7 +225,7 @@ RSpec.describe EmailHelper::Probe, integration: true do
               setting: include(
                 outbound: include(
                   options: include(
-                    host: outbound_host,
+                    host: host,
                   ),
                 ),
               ),
@@ -269,33 +233,8 @@ RSpec.describe EmailHelper::Probe, integration: true do
         end
       end
 
-      context 'with zammad', required_envs: %w[EMAILHELPER_MAILBOX_1] do
-        let(:real_user_data) { ENV['EMAILHELPER_MAILBOX_1'].split(':') }
-        let(:inbound_host)   { 'mx2.zammad.com' }
-        let(:outbound_host)  { inbound_host }
-
-        before do
-          stub_const('Channel::Driver::Smtp::DEFAULT_OPEN_TIMEOUT', 5.seconds)
-          stub_const('Channel::Driver::Smtp::DEFAULT_READ_TIMEOUT', 10.seconds)
-
-          options = {
-            host:      inbound_host,
-            port:      993,
-            ssl:       true,
-            auth_type: 'PLAIN',
-            user:      email,
-            password:  password,
-          }
-          imap_delete_old_mails(options)
-        end
-
-        include_examples 'do real testing'
-      end
-
-      context 'with gmail', required_envs: %w[EMAILHELPER_MAILBOX_2] do
-        let(:real_user_data) { ENV['EMAILHELPER_MAILBOX_2'].split(':') }
-        let(:inbound_host)   { 'pop.gmail.com' }
-        let(:outbound_host)  { 'smtp.gmail.com' }
+      context 'when doing a real test' do
+        let(:host) { ENV['MAIL_SERVER'] }
 
         include_examples 'do real testing'
       end

+ 29 - 71
spec/lib/email_helper/verify_spec.rb

@@ -2,80 +2,38 @@
 
 require 'rails_helper'
 
-RSpec.describe EmailHelper::Verify, integration: true do
+RSpec.describe EmailHelper::Verify, integration: true, required_envs: %w[MAIL_SERVER MAIL_ADDRESS MAIL_PASS] do
   describe '#email' do
     subject(:verify_result) { described_class.email(verify_params) }
 
-    context 'when doing real tests' do
-      let(:mailbox_user)     { real_user_data.first }
-      let(:mailbox_password) { real_user_data.last }
-
-      shared_examples 'do real testing' do
-        it { is_expected.to include(result: 'ok') }
-      end
-
-      context 'with zammad', required_envs: %w[EMAILHELPER_MAILBOX_1] do
-        let(:real_user_data) { ENV['EMAILHELPER_MAILBOX_1'].split(':') }
-
-        let(:verify_params) do
-          {
-            inbound:  {
-              adapter: 'imap',
-              options: {
-                host:     'mx2.zammad.com',
-                port:     993,
-                ssl:      true,
-                user:     mailbox_user,
-                password: mailbox_password,
-              },
-            },
-            outbound: {
-              adapter: 'smtp',
-              options: {
-                host:     'mx2.zammad.com',
-                port:     587,
-                user:     mailbox_user,
-                password: mailbox_password,
-              },
-            },
-            sender:   mailbox_user,
-          }
-        end
-
-        include_examples 'do real testing'
-      end
-
-      context 'with gmail', required_envs: %w[EMAILHELPER_MAILBOX_2] do
-        let(:real_user_data) { ENV['EMAILHELPER_MAILBOX_2'].split(':') }
-
-        let(:verify_params) do
-          {
-            inbound:  {
-              adapter: 'pop3',
-              options: {
-                host:     'pop.gmail.com',
-                port:     995,
-                ssl:      true,
-                user:     mailbox_user,
-                password: mailbox_password,
-              },
-            },
-            outbound: {
-              adapter: 'smtp',
-              options: {
-                host:      'smtp.gmail.com',
-                port:      587,
-                start_tls: true,
-                user:      mailbox_user,
-                password:  mailbox_password,
-              },
-            },
-            sender:   mailbox_user,
-          }
-        end
-
-        include_examples 'do real testing'
-      end
+    let(:mailbox_user)     { ENV['MAIL_ADDRESS'] }
+    let(:mailbox_password) { ENV['MAIL_PASS'] }
+    let(:verify_params) do
+      {
+        inbound:  {
+          adapter: 'imap',
+          options: {
+            host:     ENV['MAIL_SERVER'],
+            port:     993,
+            ssl:      true,
+            user:     mailbox_user,
+            password: mailbox_password,
+          },
+        },
+        outbound: {
+          adapter: 'smtp',
+          options: {
+            host:     ENV['MAIL_SERVER'],
+            port:     25,
+            ssl:      false,
+            user:     mailbox_user,
+            password: mailbox_password,
+          },
+        },
+        sender:   mailbox_user,
+      }
     end
+
+    it { is_expected.to include(result: 'ok') }
   end
 end

+ 24 - 26
spec/lib/email_helper_spec.rb

@@ -3,6 +3,8 @@
 require 'rails_helper'
 
 RSpec.describe EmailHelper do
+
+  # This should continue to be a live test using DNS.
   describe '#mx_records', integration: true do
     context 'when checking for regular domains' do
       subject(:result) { described_class.mx_records(domain) }
@@ -79,20 +81,19 @@ RSpec.describe EmailHelper do
     end
   end
 
-  describe '#provider_inbound_mx', integration: true do
-    subject(:result) { described_class.provider_inbound_mx(user, email, password, mx_domains) }
+  describe '#provider_inbound_mx' do
+    subject(:result) { described_class.provider_inbound_mx(user, email, password, [mx_domain]) }
 
     let(:email)        { 'linus@zammad.com' }
     let(:password)     { 'some_pw' }
-    let(:parsed_email) { described_class.parse_email(email) }
-    let(:user)         { parsed_email.first }
-    let(:domain)       { parsed_email.last }
-    let(:mx_domains)   { described_class.mx_records(domain) }
+    let(:user)         { 'linus' }
+    let(:domain)       { 'zammad.com' }
+    let(:mx_domain)    { 'mx2.zammad.com' }
 
     let(:expected_result) do
       [
-        provider_inbound_mx_setting(mx_domains[0], 993, user, password),
-        provider_inbound_mx_setting(mx_domains[0], 993, email, password),
+        provider_inbound_mx_setting(mx_domain, 993, user, password),
+        provider_inbound_mx_setting(mx_domain, 993, email, password),
       ]
     end
 
@@ -117,9 +118,8 @@ RSpec.describe EmailHelper do
 
     let(:email)        { 'linus@zammad.com' }
     let(:password)     { 'some_pw' }
-    let(:parsed_email) { described_class.parse_email(email) }
-    let(:user)         { parsed_email.first }
-    let(:domain)       { parsed_email.last }
+    let(:user)         { 'linus' }
+    let(:domain)       { 'zammad.com' }
 
     let(:expected_result) do
       [
@@ -152,24 +152,23 @@ RSpec.describe EmailHelper do
     it { is_expected.to eq(expected_result) }
   end
 
-  describe '#provider_outbound_mx', integration: true do
-    subject(:result) { described_class.provider_outbound_mx(user, email, password, mx_domains) }
+  describe '#provider_outbound_mx' do
+    subject(:result) { described_class.provider_outbound_mx(user, email, password, [mx_domain]) }
 
     let(:email)        { 'linus@zammad.com' }
     let(:password)     { 'some_pw' }
-    let(:parsed_email) { described_class.parse_email(email) }
-    let(:user)         { parsed_email.first }
-    let(:domain)       { parsed_email.last }
-    let(:mx_domains)   { described_class.mx_records(domain) }
+    let(:user)         { 'linus' }
+    let(:domain)       { 'zammad.com' }
+    let(:mx_domain)    { 'mx.zammad.com' }
 
     let(:expected_result) do
       [
-        provider_outbound_mx_setting(mx_domains[0], 465, true, user, password),
-        provider_outbound_mx_setting(mx_domains[0], 465, true, email, password),
-        provider_outbound_mx_setting(mx_domains[0], 587, nil, user, password),
-        provider_outbound_mx_setting(mx_domains[0], 587, nil, email, password),
-        provider_outbound_mx_setting(mx_domains[0], 25, true, user, password),
-        provider_outbound_mx_setting(mx_domains[0], 25, true, email, password),
+        provider_outbound_mx_setting(mx_domain, 465, true, user, password),
+        provider_outbound_mx_setting(mx_domain, 465, true, email, password),
+        provider_outbound_mx_setting(mx_domain, 587, nil, user, password),
+        provider_outbound_mx_setting(mx_domain, 587, nil, email, password),
+        provider_outbound_mx_setting(mx_domain, 25, true, user, password),
+        provider_outbound_mx_setting(mx_domain, 25, true, email, password),
       ]
     end
 
@@ -199,9 +198,8 @@ RSpec.describe EmailHelper do
 
     let(:email)        { 'linus@zammad.com' }
     let(:password)     { 'some_pw' }
-    let(:parsed_email) { described_class.parse_email(email) }
-    let(:user)         { parsed_email.first }
-    let(:domain)       { parsed_email.last }
+    let(:user)         { 'linus' }
+    let(:domain)       { 'zammad.com' }
 
     let(:expected_result) do
       [

+ 3 - 3
spec/system/channels/email_spec.rb

@@ -4,7 +4,7 @@ require 'rails_helper'
 
 RSpec.describe 'Manage > Channels > Email', type: :system do
 
-  context 'when managing email channels', required_envs: %w[MAILBOX_INIT] do
+  context 'when managing email channels', required_envs: %w[MAIL_ADDRESS MAIL_PASS] do
 
     before do
       visit '/#channels/email'
@@ -28,8 +28,8 @@ RSpec.describe 'Manage > Channels > Email', type: :system do
     end
 
     context 'when creating new channels' do
-      let(:mailbox_user)     { ENV['MAILBOX_INIT'].split(':')[0] }
-      let(:mailbox_password) { ENV['MAILBOX_INIT'].split(':')[1] }
+      let(:mailbox_user)     { ENV['MAIL_ADDRESS'] }
+      let(:mailbox_password) { ENV['MAIL_PASS'] }
 
       before do
         # Make sure the channel is loaded

+ 3 - 3
spec/system/setup/system_spec.rb

@@ -2,7 +2,7 @@
 
 require 'rails_helper'
 
-RSpec.describe 'System setup process', authenticated_as: false, required_envs: %w[MAILBOX_INIT], set_up: false, type: :system do
+RSpec.describe 'System setup process', authenticated_as: false, required_envs: %w[MAIL_ADDRESS MAIL_PASS], set_up: false, type: :system do
 
   def fqdn
     match_data = %r{://(.+?)(:.+?|/.+?|)$}.match(app_host)
@@ -13,8 +13,8 @@ RSpec.describe 'System setup process', authenticated_as: false, required_envs: %
 
   it 'Setting up a new system' do
 
-    mailbox_user     = ENV['MAILBOX_INIT'].split(':')[0]
-    mailbox_password = ENV['MAILBOX_INIT'].split(':')[1]
+    mailbox_user     = ENV['MAIL_ADDRESS']
+    mailbox_password = ENV['MAIL_PASS']
 
     visit '/'
 

+ 4 - 5
test/browser/aaa_getting_started_test.rb

@@ -4,13 +4,12 @@ require 'browser_test_helper'
 
 class AaaGettingStartedTest < TestCase
   def test_a_getting_started
-    if !ENV['MAILBOX_INIT']
-      # raise "Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@zammad.com:somepass'"
-      puts "NOTICE: Need MAILBOX_INIT as ENV variable like export MAILBOX_INIT='unittest01@zammad.com:somepass'"
+    if !ENV['MAIL_ADDRESS'] || !ENV['MAIL_PASS']
+      puts 'NOTICE: Need MAIL_ADDRESS and MAIL_PASS as ENV variables.'
       return
     end
-    mailbox_user     = ENV['MAILBOX_INIT'].split(':')[0]
-    mailbox_password = ENV['MAILBOX_INIT'].split(':')[1]
+    mailbox_user     = ENV['MAIL_ADDRESS']
+    mailbox_password = ENV['MAIL_PASS']
 
     @browser = browser_instance
     location(url: browser_url)

+ 7 - 8
test/integration/email_deliver_test.rb

@@ -11,20 +11,19 @@ class EmailDeliverTest < ActiveSupport::TestCase
     if ENV['MAIL_SERVER'].blank?
       raise "Need MAIL_SERVER as ENV variable like export MAIL_SERVER='mx.example.com'"
     end
-    if ENV['MAIL_SERVER_ACCOUNT'].blank?
-      raise "Need MAIL_SERVER_ACCOUNT as ENV variable like export MAIL_SERVER_ACCOUNT='user:somepass'"
+    if ENV['MAIL_ADDRESS'].blank?
+      raise "Need MAIL_ADDRESS as ENV variable like export MAIL_ADDRESS='someunitest@example.com'"
     end
-
-    if ENV['MAIL_SERVER_EMAIL'].blank?
-      raise "Need MAIL_SERVER_EMAIL as ENV variable like export MAIL_SERVER_EMAIL='someunitest@example.com'"
+    if ENV['MAIL_PASS'].blank?
+      raise "Need MAIL_PASS as ENV variable like export MAIL_PASS='someunitest@example.com'"
     end
 
-    server_login = ENV['MAIL_SERVER_ACCOUNT'].split(':')[0]
-    server_password = ENV['MAIL_SERVER_ACCOUNT'].split(':')[1]
+    server_login = ENV['MAIL_ADDRESS']
+    server_password = ENV['MAIL_PASS']
 
     email_address = EmailAddress.create!(
       realname:      'me Helpdesk',
-      email:         "some-zammad-#{ENV['MAIL_SERVER_EMAIL']}",
+      email:         "some-zammad-#{ENV['MAIL_ADDRESS']}",
       updated_by_id: 1,
       created_by_id: 1,
     )

+ 12 - 9
test/integration/email_keep_on_server_test.rb

@@ -6,15 +6,18 @@ require 'net/imap'
 class EmailKeepOnServerTest < ActiveSupport::TestCase
   setup do
 
-    if ENV['KEEP_ON_MAIL_SERVER'].blank?
-      raise "Need KEEP_ON_MAIL_SERVER as ENV variable like export KEEP_ON_MAIL_SERVER='mx.example.com'"
+    if ENV['MAIL_SERVER'].blank?
+      raise "Need MAIL_SERVER as ENV variable like export MAIL_SERVER='mx.example.com'"
     end
-    if ENV['KEEP_ON_MAIL_SERVER_ACCOUNT'].blank?
-      raise "Need KEEP_ON_MAIL_SERVER_ACCOUNT as ENV variable like export KEEP_ON_MAIL_SERVER_ACCOUNT='user:somepass'"
+    if ENV['MAIL_ADDRESS'].blank?
+      raise 'Need MAIL_ADDRESS as ENV variable'
+    end
+    if ENV['MAIL_PASS'].blank?
+      raise 'Need MAIL_PASS as ENV variable'
     end
 
-    @server_login = ENV['KEEP_ON_MAIL_SERVER_ACCOUNT'].split(':')[0]
-    @server_password = ENV['KEEP_ON_MAIL_SERVER_ACCOUNT'].split(':')[1]
+    @server_login = ENV['MAIL_ADDRESS']
+    @server_password = ENV['MAIL_PASS']
 
     @folder = "keep_on_mail_server_#{SecureRandom.uuid}"
 
@@ -39,7 +42,7 @@ class EmailKeepOnServerTest < ActiveSupport::TestCase
         inbound:  {
           adapter: 'imap',
           options: {
-            host:     ENV['KEEP_ON_MAIL_SERVER'],
+            host:     ENV['MAIL_SERVER'],
             user:     @server_login,
             password: @server_password,
             ssl:      true,
@@ -65,7 +68,7 @@ class EmailKeepOnServerTest < ActiveSupport::TestCase
     @channel.save!
 
     # clean mailbox
-    imap = Net::IMAP.new(ENV['KEEP_ON_MAIL_SERVER'], 993, true, nil, false)
+    imap = Net::IMAP.new(ENV['MAIL_SERVER'], 993, true, nil, false)
     imap.login(@server_login, @server_password)
     imap.create(@folder)
     imap.select(@folder)
@@ -153,7 +156,7 @@ hello world
     @channel.save!
 
     # clean mailbox
-    imap = Net::IMAP.new(ENV['KEEP_ON_MAIL_SERVER'], 993, true, nil, false)
+    imap = Net::IMAP.new(ENV['MAIL_SERVER'], 993, true, nil, false)
     imap.login(@server_login, @server_password)
     imap.create(@folder)
     imap.select(@folder)

+ 11 - 8
test/integration/email_postmaster_to_sender.rb

@@ -14,25 +14,28 @@ class EmailPostmasterToSender < ActiveSupport::TestCase
     if ENV['MAIL_SERVER'].blank?
       raise "Need MAIL_SERVER as ENV variable like export MAIL_SERVER='mx.example.com'"
     end
-    if ENV['MAIL_SERVER_ACCOUNT'].blank?
-      raise "Need MAIL_SERVER_ACCOUNT as ENV variable like export MAIL_SERVER_ACCOUNT='user:somepass'"
+    if ENV['MAIL_ADDRESS'].blank?
+      raise 'Need MAIL_ADDRESS as ENV variable'
+    end
+    if ENV['MAIL_PASS'].blank?
+      raise 'Need MAIL_PASS as ENV variable'
     end
 
     @server_address = ENV['MAIL_SERVER']
-    @server_login = ENV['MAIL_SERVER_ACCOUNT'].split(':')[0]
-    @server_password = ENV['MAIL_SERVER_ACCOUNT'].split(':')[1]
+    @server_login = ENV['MAIL_ADDRESS']
+    @server_password = ENV['MAIL_PASS']
 
     @folder = "postmaster_to_sender_#{@test_id}"
 
-    if ENV['MAIL_SERVER_EMAIL'].blank?
-      raise "Need MAIL_SERVER_EMAIL as ENV variable like export MAIL_SERVER_EMAIL='admin@example.com'"
+    if ENV['MAIL_ADDRESS'].blank?
+      raise "Need MAIL_ADDRESS as ENV variable like export MAIL_ADDRESS='admin@example.com'"
     end
 
-    @sender_email_address = ENV['MAIL_SERVER_EMAIL']
+    @sender_email_address = ENV['MAIL_ADDRESS']
 
     @email_address = EmailAddress.create!(
       realname:      'me Helpdesk',
-      email:         "some-zammad-#{ENV['MAIL_SERVER_EMAIL']}",
+      email:         "some-zammad-#{ENV['MAIL_ADDRESS']}",
       updated_by_id: 1,
       created_by_id: 1,
     )