Gitlab SMTP Email - Office 365

I’m trying to get our gitlab instance to send email with o365 and I’m getting nowhere. I’ve tried several combinations of settings and nothing has worked and the documentation for using Office 365 is non-existent and the logs only help a little.

I’m getting some kind of SSL/TLS errors, but I have no idea how to proceed fixing it. Any help would be appreciated.

Config:
#gitlab_rails[‘smtp_enable’] = true
#gitlab_rails[‘smtp_address’] = “smtp.office365.com
#gitlab_rails[‘smtp_port’] = 587
#gitlab_rails[‘smtp_user_name’] = “gitlab@sub.domain.com
#gitlab_rails[‘gitlab_email_from’] = “gitlab@domain.com
#gitlab_rails[‘smtp_password’] = “password”
#gitlab_rails[‘smtp_domain’] = “domain.com
#gitlab_rails[‘smtp_authentication’] = ‘login’
#gitlab_rails[‘smtp_enable_starttls_auto’] = true
#gitlab_rails[‘smtp_tls’] = true
#gitlab_rails[‘smtp_openssl_verify_mode’] = ‘peer’
#gitlab_rails[‘smtp_ca_path’] = “/etc/ssl/certs”
#gitlab_rails[‘smtp_ca_file’] = “/etc/ssl/certs/ca-certificates.crt”

Error(s):

If I turn on “smt_tls” I get the following popping up in the logs:

WARN: OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol

If I leave it to false I get a different error

Net::SMTPFatalError: 550 5.7.60 SMTP; Client does not have permissions to send as this sender 

I suspect I’m closer with that second error… but I’m not sure how to fix it. Shouldn’t gitlab simply be authenticating with the account I’ve provided it and sending emails with it? Why would any other ‘client’ need send as permissions on the account?

This has been the most difficult time I’ve ever had setting up something some simple…

Nobody’s got anything for me?

What’s the point of a community forum if nobody responds?

Hello Scully,

it is hard to see what you configured because all lines seem to be commented out, so I am not sure what you really activated. Beforehand: we neither use Office365 nor do I have to authenticate to contact our internal SMTP server.

A blind guess for the second error (550):

  • Your server sends your own certificate. This one is not known to Outlook, hence the error.
  • Try to comment or delete the smtp_ca lines resp. move the crt file out of the way.

HTH

Hey Scully,

Also been fighting with this and just got it. Finally got it to work with the following settings:

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.office365.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "gitlab_admin@mydomain.com"
gitlab_rails['smtp_password'] = “[REDACTED]”
gitlab_rails['smtp_domain'] = “mydomain.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-certificates.crt"

Only thing that stands out from your settings is that I’m not using a subdomain for smtp_user_name. Unless that’s set as the UPN for login on O365, which would explain the credential rejection.

Also - my smoking gun ended up being the smtp_tls, but with a strange issue I cant explain. After setting that to false and running sudo gitlab-ctl reconfigure it still didnt work. For some reason I ran sudo gitlab-ctl restart and everything started working.

Hope that helps!

I have the same issue, try to use the configuration from @albrechs

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.office365.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "personal_user@mydomain.com"
gitlab_rails['smtp_password'] = “personal_password”
gitlab_rails['smtp_domain'] = “mydomain.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false

but have no luck, still got the issue:

Net::SMTPFatalError: 550 5.7.60 SMTP; Client does not have permissions to send as this sender

Any idea how to fix this?

I have tried to use powershell code to Send-MailMessage with my username and password, it works! So not sure what were missing in smtp configuration

Seems I have found the solution, you have to change the email from to the one you are using for the authentication

gitlab_rails['gitlab_email_from'] = 'personal_user@mydomain.com'

Cheers,

2 Likes