In short, I tried setting up GitLab with Microsoft Cloud, but it didn’t work unless I paid. So, I used Sendinblue instead.
The email setup comes after the gitlab setup which I explained here: https://afeser.duckdns.org/2024/06/21/setting-up-gitlab-nginx/
Setting Up with Office365 (failed)
I tried all 3 approaches given in this link: https://learn.microsoft.com/en-gb/Exchange/mail-flow-best-practices/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-microsoft-365-or-office-365
First approach
First link failed because, as given in the note, the new authentication does not allow users to connect via SMTP and send an e-mail. If you try with test function:
sudo gitlab-rails console # and write the below command in the console
Notify.test_email('destination_email@address.com', 'Message Subject', 'Message Body').deliver_now
it will complain your company policy requires two phase authentication, which I am not sure how to implement. In Azure platform, you can change the policy for different users, but it will ask you money just to set this. Therefore, I was just angry at it and didn’t use this approach.
Second approach
Second approach also failed because it is not secure. You also need to account for anyone on the server. So, simply this is also not working.
Third approach
This is basically the same as the second approach, but this can also send e-mails to the external users. Anyway, this does not work due to the same reason.
Sendinblu
Sendinblue allows up to 300 mails free per day, which is more than enough for my purposes. I created account, and created an API key for e-mails. Then I go to SMTP & API and generated a key. It looks like this:
![](https://afeser.duckdns.org/wp-content/uploads/2024/06/image-4-1024x200.png)
However, I used the gitlab configuration given here = https://docs.gitlab.com/omnibus/settings/smtp.html#brevo because, the port given above did not work.
I edited file /etc/gitlab/gitlab.rb
and added this at the end:
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp-relay.sendinblue.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "<username@example.com>" # https://app.brevo.com/settings/keys/smtp
gitlab_rails['smtp_password'] = "<password>" # https://app.brevo.com/settings/keys/smtp
gitlab_rails['smtp_domain'] = "<example.com>"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = false
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '<gitlab@example.com>'
gitlab_rails['gitlab_email_reply_to'] = '<noreply@example.com>'
Then reconfigure the gitlab service:
gitlab-ctl reconfigure
# and test
sudo gitlab-rails console # and write the below command in the console
Notify.test_email('destination_email@address.com', 'Message Subject', 'Message Body').deliver_now
Leave a Reply