Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab email setup: sending via another mail server

By default gitlab has the next configuration in gitlab.yml :

email:
  from: [email protected]
  host: gitlabhq.com

but, I need to specify other variables (host, port, user, password, etc) to use another mail server.

How I do that?

like image 476
el_quick Avatar asked May 21 '12 18:05

el_quick


4 Answers

Now it is totally different in Gitlab 5.2+.

It is in "/home/git/gitlab/config/initializers/smtp_settings.rb.sample" and we just need to follow the instructions in that.

like image 73
Girish KG Avatar answered Nov 02 '22 23:11

Girish KG


Note: This method was useful for older versions of Gitlab. See the answer of Girish for newer versions.


At the end of config/environments/production.rb you can add something like this:

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
      :address => 'yourserver.com',
      :port => 25,
      :domain => 'gitlab.yourserver.com',
      :authentication => :plain,
      :user_name => '[email protected]',
      :password => 'yourPassword',
      :enable_starttls_auto => true
  }

Refer to the ActionMailer documentation for a more detailed description of possible configurations: http://api.rubyonrails.org/classes/ActionMailer/Base.html

Note: You may have to edit the file again after a Gitlab update

like image 40
Adrian Avatar answered Nov 02 '22 23:11

Adrian


This confused me too. But to change the mail setting you edit them in config/environments/production.rb Just add a config.action_mailer.smtp_settings like a regular rails app.

like image 10
Joshua Avatar answered Nov 02 '22 22:11

Joshua


For Gitlab > 7 omnibus, edit /etc/gitlab/gitlab.rb as below and run sudo gitlab-ctl reconfigure

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.server"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "smtp user"
gitlab_rails['smtp_password'] = "smtp password"
gitlab_rails['smtp_domain'] = "example.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_openssl_verify_mode'] = 'none'

Source: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/smtp.md

like image 7
topher Avatar answered Nov 02 '22 22:11

topher