Cannot send emails through office 365 SMTP


#1

Hi,

I am trying to set up my Gitlab instance to send out emails through our Office 365 SMTP.

I have followed this guide and below are my settings

gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “smtp.office365.com
gitlab_rails[‘smtp_port’] = 587
gitlab_rails[‘smtp_user_name’] = "gitlab@domain.com"
gitlab_rails[‘smtp_password’] = “xxxx”
gitlab_rails[‘smtp_domain’] = “domain.com
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = true
#gitlab_rails[‘smtp_tls’] = false
#gitlab_rails[‘smtp_openssl_verify_mode’] = ‘none’
#gitlab_rails[‘smtp_ca_path’] = ‘/etc/ssl/certs’
#gitlab_rails[‘smtp_ca_file’] = ‘/etc/ssl/certs/ca-bundle.crt’
gitlab_rails[‘smtp_openssl_verify_mode’] = ‘peer’

When I try to send a test through gitlab-rails console I get the below error

Net::SMTPFatalError: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 16.55847:EF100000, 17.43559:0000000094000000000000000100000000000000, 20.52176:140F41860B0010100300170E, 20.50032:140F41867B1710100A000281, 0.35180:E7020000, 255.23226:0A008440, 255.27962:0A000000, 255.27962:0E000000, 255.31418:0A000000, 16.55847:9A000000, 17.43559:0000000070010000000000000100000000000000, 20.52176:140F41860B00101003000136, 20.50032:140F41867B1710100A00DA36, 0.35180:44000000, 255.23226:4800D13D, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:0A003A66, 4.21921:DC040000, 255.27962:FA000000, 255.1494:64000000, 0.38698:0F010480, 0.37692:0F010480, 0.37948:0F010480, 5.33852:00000000534D545000000100, 4.56248:DC040000, 7.40748:010000000000010B1A010480, 7.57132:00000000000000001A010480, 1.63016:32000000, 4.39640:DC040000, 8.45434:1E9BECDC044CC1409D215FCC910D16BD00000000, 5.10786:0000000031352E32302E313630312E3031313A414D36505230334D42333836313A32393061663765622D653436612D343233322D613761322D3962323662376362663966610040101A010480, 255.1750:A0000000, 255.31418:0A005636, 0.22753:A5000000, 255.21817:DC040000, 4.60547:DC040000, 0.21966:03003866, 4.30158:DC040000 [Hostname=AM6PR03MB3861.eurprd03.prod.outlook.com]

    from /opt/gitlab/embedded/lib/ruby/2.4.0/net/smtp.rb:969:in `check_response'
    from /opt/gitlab/embedded/lib/ruby/2.4.0/net/smtp.rb:914:in `data'
    from /opt/gitlab/embedded/lib/ruby/2.4.0/net/smtp.rb:659:in `block in send_message'
    from /opt/gitlab/embedded/lib/ruby/2.4.0/net/smtp.rb:854:in `rcptto_list'
    from /opt/gitlab/embedded/lib/ruby/2.4.0/net/smtp.rb:659:in `send_message'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/mail-2.7.0/lib/mail/network/delivery_methods/smtp_connection.rb:54:in `deliver!'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/mail-2.7.0/lib/mail/network/delivery_methods/smtp.rb:101:in `block in deliver!'
    from /opt/gitlab/embedded/lib/ruby/2.4.0/net/smtp.rb:519:in `start'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/mail-2.7.0/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/mail-2.7.0/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/mail-2.7.0/lib/mail/message.rb:2160:in `do_delivery'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/mail-2.7.0/lib/mail/message.rb:260:in `block in deliver'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/actionmailer-4.2.10/lib/action_mailer/base.rb:543:in `block in deliver_mail'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `block in instrument'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/activesupport-4.2.10/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `instrument'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/actionmailer-4.2.10/lib/action_mailer/base.rb:541:in `deliver_mail'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/mail-2.7.0/lib/mail/message.rb:260:in `deliver'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/actionmailer-4.2.10/lib/action_mailer/message_delivery.rb:85:in `deliver_now'
    from (irb):1
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/console.rb:110:in `start'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/console.rb:9:in `start'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /opt/gitlab/embedded/lib/ruby/gems/2.4.0/gems/railties-4.2.10/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:14:in `require'
    from bin/rails:14:in `<main>'

I have sent an email from the account itself and it worked fine.

What could be the issue?

Thanks