Gitlab SMTP Office 365 configuration on ec2 instance

Hello Folks,

I’ve tried to configure Gitlab SMTP email configuration using office 365. but I always ended up following error Net::SMTPAuthenticationError (535 5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator. even though i’ve right credential. If anyone knows the solution kindly replay in this thread, it would be really appreciated!.

Here is my configuration:-

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.office365.com"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "yourmail.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_openssl_verify_mode'] = 'peer'
gitlab_rails['gitlab_email_from'] = "yourmail.domain.com"

Did you ever get to the bottom of that?
Was the problem related to 2FA and you were not using app password?

I am actively trying to get this to work in combination with Microsoft 365 E5. The first error was caused by SMTP AUTH being turned off, which has to be active to use the SMTP relay. After turning it on, I have been stuck on the exact same error message as you. I have tried multiple different approaches at this point, such as setting it up as an enterprise application and attaching the SMTP.Send policy to it.

At this point I believe has something to do with the conditional access in Microsoft Entra ID, which is primarily motivated by the error it prints.
It seems like there is an initial connection, but the GitLab server doesn’t meet the access criteria set by Conditional Access. I haven’t had a change to mess around with the policies yet.

Searching the web hasn’t resulted in a resolution yet, so I’ll experimenting and hopefully I am eventually able to share the steps to get it to work.