Set up SMTP mail for Gitlab CE

by Daniel Pham
Published: Updated:
This entry is part 3 of 9 in the series Install Gitlab CE on Ubuntu 18

Set up SMTP mail for Gitlab CE. After you have set up users to authenticate using LDAP, you will need to set up a system that can send emails to users.

Set up SMTP mail for Gitlab CE
Set up SMTP mail for Gitlab CE.

Set up SMTP mail for Gitlab CE

About email setup documentation for gitlab server, you can see here.

First, open gitlab’s configuration file.

nano /etc/gitlab/gitlab.rb

Then you find and edit the lines into the following content.

gitlab_rails['smtp_enable'] = true                              # Enable SMTP to send mail
gitlab_rails['smtp_address'] = ""            # SMTP server address, you can use for gmail
gitlab_rails['smtp_port'] = 465                                 # 465 connection port
gitlab_rails['smtp_user_name'] = "[email protected]"        # Địa chỉ email sử dụng để gửi mail từ máy chủ
gitlab_rails['smtp_password'] = "abc123"                        # Password corresponds to the email above. This password section avoids characters limited to use in Ruby or YAML (e.g. ').
gitlab_rails['smtp_domain'] = ""                  # SMTP domain is setting up, for example:,
gitlab_rails['smtp_authentication'] = "login"                   # Choose the smtp login method with the username and password declared above
gitlab_rails['smtp_enable_starttls_auto'] = true                # Automatic TLS connection
gitlab_rails['smtp_tls'] = true                                 # Select TLS encryption method
gitlab_rails['gitlab_email_from'] = '[email protected]'     # Similar to the email address above used
gitlab_rails['gitlab_email_display_name'] = 'Gitlab System'     # Specify the display name to use for mail
gitlab_rails['gitlab_email_reply_to'] = '[email protected]' # Set up a reply to email address

You save the changed file and apply the new configuration to the gitlab server.

gitlab-ctl reconfigure

Test sending email

For Gitlab EE version (enterprise version), there will be a button to send test mail in the admin interface.

With the Gitlab CE version, that feature is limited. Therefore, we will have to test sending mail through the console.

First, you enter the console interface with the following command.

gitlab-rails console

It will appear in the command window looking like this.

 GitLab:       13.2.2 (64fc0138d55) FOSS
 GitLab Shell: 13.3.0
 PostgreSQL:   11.7
Loading production environment (Rails

Next, type the following command to test sending mail.

Notify.test_email('[email protected]', 'Send test mail gitlab', 'send mail from console').deliver_now

In there:

  • [email protected]: Email address of the test mail recipient
  • Send test mail gitlab: email subject
  • send mail from console: email content

If the test mail is sent successfully, the console will return results that look like this.

Set up SMTP mail for Gitlab CE
Mail test results from console.


With this article, you have successfully set up the email sending feature for the internal Gitlab CE server.

Note the firewall port: you need to open OUTBOUND ports: 25, 465, 587.

0 0 votes
Article Rating
Series Navigation«« Previous part: Set up LDAP authentication for Gitlab CENext part: Backup and restore data for Gitlab CE »»

You may also like

Notify of
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.



Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 – All rights reserved.

Please write sources “” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Would love your thoughts, please comment.x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.