SMTP settings in GitLab2 min read

Prabhin Prabharkaran Administrator
DevOps Engineer

He is a Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!

follow me

SMTP settings in GitLab
In this document we share you how to setup SMTP settings in GitLab. Till now gitlab doesn’t have a UI developed for setting up from address. This is how it’s done in backend.

 

FOR GMAIL

If you are using gmail address for sending mail, it’s not recommended not use since google has its own limit for bulk sending emails which may result blocking your mail id considering it as a spammmer. So a subscribe for Amazon SES or mailtrap/sendgrid and do a verification.

Email configuration are done in /etc/gitlab/gitlab.rb configuration file and make sure that to run gitlab-ctl reconfigure after doing configuration changes.

Add the following lines to /etc/gitlab/gitlab.rb

 

gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “smtp.gmail.com”
gitlab_rails[‘smtp_port’] = 587
gitlab_rails[‘smtp_user_name’] = “yourEMAIL@gmail.com”
gitlab_rails[‘smtp_password’] = “EMAIL-password”
gitlab_rails[‘smtp_domain’] = “smtp.gmail.com”
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘smtp_tls’] = false
gitlab_rails[‘smtp_openssl_verify_mode’] = ‘peer’

 

FOR AMAZON SES

Make sure that you have verified the mail id and created IAM user for that.

 

gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “email-smtp.region-1.amazonaws.com”
gitlab_rails[‘smtp_port’] = 587
gitlab_rails[‘smtp_user_name’] = “IAMmailUSERKey”
gitlab_rails[‘smtp_password’] = “IAMmailUSERSecret”
gitlab_rails[‘smtp_domain’] = “URdomain.com”
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = true

 

 

FOR OUTLOOK

 

gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “smtp-mail.outlook.com”
gitlab_rails[‘smtp_port’] = 587
gitlab_rails[‘smtp_user_name’] = “username@outlook.com”
gitlab_rails[‘smtp_password’] = “password”
gitlab_rails[‘smtp_domain’] = “smtp-mail.outlook.com”
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘smtp_openssl_verify_mode’] = ‘peer’

 

FOR o365

gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “smtp.office365.com”
gitlab_rails[‘smtp_port’] = 587
gitlab_rails[‘smtp_user_name’] = “username@yourdomain.com”
gitlab_rails[‘smtp_password’] = “password”
gitlab_rails[‘smtp_domain’] = “yourdomain.com”
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘smtp_openssl_verify_mode’] = ‘peer’

FOR SENDGRID

gitlab_rails[‘smtp_enable’] = true
gitlab_rails[‘smtp_address’] = “smtp.sendgrid.net”
gitlab_rails[‘smtp_port’] = 587
gitlab_rails[‘smtp_user_name’] = “a_sendgrid_crendential”
gitlab_rails[‘smtp_password’] = “a_sendgrid_password”
gitlab_rails[‘smtp_domain’] = “smtp.sendgrid.net”
gitlab_rails[‘smtp_authentication’] = “login”
gitlab_rails[‘smtp_enable_starttls_auto’] = true
gitlab_rails[‘smtp_tls’] = false

 

 

Testing the SMTP configuration

You can verify GitLab’s ability to send emails properly using the Rails console. On the GitLab server, execute gitlab-rails console to enter the console. Then, you can enter the following command at the console prompt to cause GitLab to send a test email:

irb(main):003:0> Notify.test_email(‘destination_email@address.com’, ‘Message Subject’, ‘Message Body

© 2018, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points

Related posts

Leave a Reply