Using an external SMTP server with GitLab
GitLab 7 (Omnibus)
Edit the /etc/gitlab/gitlab.rb
file to match your SMTP servers settings and credentials. e.g.:
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.server"
gitlab_rails['smtp_port'] = 456
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
# If your SMTP server does not like the default 'From: gitlab@localhost' you
# can change the 'From' with this setting.
gitlab_rails['gitlab_email_from'] = 'gitlab@example.com'
Now run:
gitlab-ctl reconfigure
Done.
GitLab 6 & 7 (Manual Install)
First edit the config/environments/production.rb
file, to configure GitLab to use SMTP by default; change the line:
config.action_mailer.delivery_method = :sendmail
to
config.action_mailer.delivery_method = :smtp
Now make a copy of the smtp_settings.rb.sample
file:
# cp config/initializers/smtp_settings.rb.sample config/initializers/smtp_settings.rb
And edit the appropiate settings (address, port, username, password, etc...):
# To enable smtp email delivery for your GitLab instance do next:
# 1. Rename this file to smtp_settings.rb
# 2. Edit settings inside this file
# 3. Restart GitLab instance
#
if Rails.env.production?
Gitlab::Application.config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: "email.server.com",
port: 465,
user_name: "smtp",
password: "123456",
domain: "gitlab.company.com",
authentication: :login,
enable_starttls_auto: true
}
end
Here are a couple of example settings:
Gmail####
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail.com',
:user_name => 'account@gmail.com',
:password => 'password',
:authentication => :plain,
:enable_starttls_auto => true
}
Mailgun####
config.action_mailer.smtp_settings = {
:address => "smtp.mailgun.org",
:port => 587,
:domain => 'gitlab.mydomain.com',
:user_name => 'user@mydomain.org',
:password => 'password',
:authentication => :plain,
:enable_starttls_auto => true
}
Restart GitLab & nginx:
# service gitlab restart
# service nginx restart
That's it, you're done.