Table of Contents
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
About email setup documentation for gitlab server, you can see here.
First, open gitlab’s configuration file.
nano /etc/gitlab/gitlab.rbThen you find and edit the lines into the following content.
gitlab_rails['smtp_enable'] = true # Enable SMTP to send mail
gitlab_rails['smtp_address'] = "mail.yourdomain.com" # 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'] = "yourdomain.com" # SMTP domain is setting up, for example: yourdomain.com, gmail.com
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 addressYou save the changed file and apply the new configuration to the gitlab server.
gitlab-ctl reconfigureTest 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 consoleIt 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 6.0.3.1)
irb(main):001:0>Next, type the following command to test sending mail.
Notify.test_email('[email protected]', 'Send test mail gitlab', 'send mail from console').deliver_nowIn 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.

Conclusion
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.