virtualMachinegitlab

Configure SMTP for outbound emails

  • To configure the outbound email settings, open the /etc/gitlab/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'] = "smtp.gmail.com"
      gitlab_rails['smtp_port'] = 587
      gitlab_rails['smtp_user_name'] = "USERNAME@gmail.com"
      gitlab_rails['smtp_password'] = "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'
    

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('USERNAME@gmail.com', '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, your application’s attempts to send outgoing emails may be blocked by Gmail if it considers the authentication attempts to be suspicious. When this happens, you will receive a Gmail security alert at the corresponding Gmail address. To proceed, you will need to manually confirm the validity of the authentication attempt before Gmail will permit the application to send outbound emails. For more information on this and other Gmail issues related to outbound email from your application, refer to our Gmail SMTP troubleshooting page.

Last modification July 3, 2024