Configure SMTP for outbound emails

  • To configure the outbound email settings, open the /opt/gitlab/etc/gitlab.rb file and edit the “GitLab email server settings” section as shown below.

    This is an example of how to configure the email settings using a Gmail account. Replace USERNAME and PASSWORD with your Gmail account username and password respectively. Remember to uncomment the following lines by removing the # at the beginning of each line:

    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = ""
    gitlab_rails['smtp_port'] = 587
    gitlab_rails['smtp_user_name'] = ""
    gitlab_rails['smtp_password'] = "PASSWORD"
    gitlab_rails['smtp_domain'] = ""
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['smtp_tls'] = false
    gitlab_rails['smtp_openssl_verify_mode'] = 'peer'

Check the GitLab official documentation to get more examples.

  • Run the following command to have the changes take effect:

    $ sudo gitlab-ctl reconfigure
  • Test if GitLab sends emails properly using the Rails console by executing the following commands. Replace USERNAME with your Gmail account username.

    $ gitlab-rails console
    $ irb(main):003:0> Notify.test_email('', 'Message Subject', 'Message Body').deliver_now

To configure the application to use other third-party SMTP services for outgoing email, such as SendGrid, refer to the FAQ.

NOTE: If you are using Gmail as the outbound email server and have experienced issues trying to send emails correctly, check the Gmail SMTP troubleshooting page to learn the causes of these issues and how to solve them.

Last modification January 18, 2019