Commit 441ea050d9e27b15bb31eaf590c2bde461bc9787

Authored by Jacob Vosmaer
1 parent aa428b11

Send application email via SMTP

CHANGELOG
1 1 7.0.0
2 2 - Specify numeric user / group identifiers
3 3 - Support AWS S3 attachment storage
  4 +- Send application email via SMTP
4 5  
5 6 6.9.0
6 7 - Make SSH port in clone URLs configurable (Julien Pivotto)
... ...
README.md
... ... @@ -440,6 +440,23 @@ gitlab_rails['aws_bucket'] = 'my_gitlab_bucket'
440 440 gitlab_rails['aws_region'] = 'us-east-1'
441 441 ```
442 442  
  443 +## Sending application email via SMTP
  444 +
  445 +If you would rather send email via an SMTP server instead of via Sendmail, add
  446 +the following configuration information to `/etc/gitlab/gitlab.rb` and run
  447 +`gitlab-ctl reconfigure`.
  448 +
  449 +```
  450 +gitlab_rails['smtp_enable'] = false
  451 +gitlab_rails['smtp_address'] = "smtp.server"
  452 +gitlab_rails['smtp_port'] = 456
  453 +gitlab_rails['smtp_user_name'] = "smtp user"
  454 +gitlab_rails['smtp_password'] = "smtp password"
  455 +gitlab_rails['smtp_domain'] = "example.com"
  456 +gitlab_rails['smtp_authentication'] = "login"
  457 +gitlab_rails['smtp_enable_starttls_auto'] = true
  458 +```
  459 +
443 460 ## Building your own package
444 461  
445 462 See [the separate build documentation](doc/build.md).
... ...
files/gitlab-cookbooks/gitlab/attributes/default.rb
... ... @@ -119,6 +119,15 @@ default['gitlab']['gitlab-rails']['db_host'] = "localhost"
119 119 default['gitlab']['gitlab-rails']['db_port'] = 5432
120 120 default['gitlab']['gitlab-rails']['db_socket'] = nil
121 121  
  122 +default['gitlab']['gitlab-rails']['smtp_enable'] = false
  123 +default['gitlab']['gitlab-rails']['smtp_address'] = nil
  124 +default['gitlab']['gitlab-rails']['smtp_port'] = nil
  125 +default['gitlab']['gitlab-rails']['smtp_user_name'] = nil
  126 +default['gitlab']['gitlab-rails']['smtp_password'] = nil
  127 +default['gitlab']['gitlab-rails']['smtp_domain'] = nil
  128 +default['gitlab']['gitlab-rails']['smtp_authentication'] = "login"
  129 +default['gitlab']['gitlab-rails']['smtp_enable_starttls_auto'] = nil
  130 +
122 131 ####
123 132 # Unicorn
124 133 ####
... ...
files/gitlab-cookbooks/gitlab/recipes/gitlab-rails.rb
... ... @@ -99,6 +99,20 @@ template_symlink File.join(gitlab_rails_etc_dir, "aws.yml") do
99 99 end
100 100 end
101 101  
  102 +template_symlink File.join(gitlab_rails_etc_dir, "smtp_settings.rb") do
  103 + link_from File.join(gitlab_rails_source_dir, "config/initializers/smtp_settings.rb")
  104 + helpers SingleQuoteHelper
  105 + owner "root"
  106 + group "root"
  107 + mode "0644"
  108 + variables(node['gitlab']['gitlab-rails'].to_hash)
  109 + restarts dependent_services
  110 +
  111 + unless node['gitlab']['gitlab-rails']['smtp_enable']
  112 + action :delete
  113 + end
  114 +end
  115 +
102 116 template_symlink File.join(gitlab_rails_etc_dir, "gitlab.yml") do
103 117 link_from File.join(gitlab_rails_source_dir, "config/gitlab.yml")
104 118 source "gitlab.yml.erb"
... ...
files/gitlab-cookbooks/gitlab/templates/default/smtp_settings.rb.erb 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +# This file is managed by gitlab-ctl. Manual changes will be
  2 +# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
  3 +# and run `sudo gitlab-ctl reconfigure`.
  4 +
  5 +if Rails.env.production?
  6 + Gitlab::Application.config.action_mailer.delivery_method = :smtp
  7 +
  8 + ActionMailer::Base.smtp_settings = {
  9 + address: <%= single_quote(@smtp_address) %>,
  10 + port: <%= @smtp_port %>,
  11 + user_name: <%= single_quote(@smtp_user_name) %>,
  12 + password: <%= single_quote(@smtp_password) %>,
  13 + domain: <%= single_quote(@smtp_domain) %>,
  14 + authentication: :<%= @smtp_authentication %>,
  15 + enable_starttls_auto: <%= @smtp_enable_starttls_auto %>
  16 + }
  17 +end
... ...