summaryrefslogtreecommitdiff
path: root/config/initializers
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2015-02-15 01:28:50 +0100
committerJakub Jirutka <jakub@jirutka.cz>2015-05-06 13:15:33 +0200
commitb4be7aed7711e51becb3be29ed82d6753cc73cc4 (patch)
treebaa0f7c67124cdbcb072a6d3834bb9c66f9b0936 /config/initializers
parent7af59c54fc1fcf9d19927e76be49318689684f8b (diff)
downloadgitlab-ce-b4be7aed7711e51becb3be29ed82d6753cc73cc4.tar.gz
Allow to configure smtp and sendmail in gitlab.yml
Diffstat (limited to 'config/initializers')
-rw-r--r--config/initializers/1_settings.rb24
-rw-r--r--config/initializers/disable_email_interceptor.rb4
-rw-r--r--config/initializers/email_settings.rb5
-rw-r--r--config/initializers/smtp_settings.rb.sample22
4 files changed, 28 insertions, 27 deletions
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index e5ac66a2323..ce0023e0795 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -105,10 +105,6 @@ Settings.gitlab['https'] = false if Settings.gitlab['https'].nil?
Settings.gitlab['port'] ||= Settings.gitlab.https ? 443 : 80
Settings.gitlab['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] || ''
Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http"
-Settings.gitlab['email_enabled'] ||= true if Settings.gitlab['email_enabled'].nil?
-Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}"
-Settings.gitlab['email_display_name'] ||= "GitLab"
-Settings.gitlab['email_reply_to'] ||= "noreply@#{Settings.gitlab.host}"
Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url)
Settings.gitlab['user'] ||= 'git'
Settings.gitlab['user_home'] ||= begin
@@ -135,6 +131,26 @@ Settings.gitlab['repository_downloads_path'] = File.absolute_path(Settings.gitla
Settings.gitlab['restricted_signup_domains'] ||= []
#
+# Outgoing emails
+#
+Settings['outgoing_emails'] ||= Settingslogic.new({})
+Settings['outgoing_emails'].tap do |opts|
+ # For backward compatibility. TODO remove in next major release.
+ opts['enabled'] ||= Settings.gitlab['email_enabled']
+ opts['from'] ||= Settings.gitlab['email_from']
+ opts['display_name'] ||= Settings.gitlab['display_name']
+ opts['reply_to'] ||= Settings.gitlab['email_reply_to']
+
+ opts['enabled'] ||= opts['enabled'].nil?
+ opts['display_name'] ||= "GitLab"
+ opts['from'] ||= "gitlab@#{Settings.gitlab.host}"
+ opts['reply_to'] ||= "noreply@#{Settings.gitlab.host}"
+ opts['delivery_method'] ||= :sendmail
+ opts['sendmail_settings'] ||= {}
+ opts['smtp_settings'] ||= {}
+end
+
+#
# Gravatar
#
Settings['gravatar'] ||= Settingslogic.new({})
diff --git a/config/initializers/disable_email_interceptor.rb b/config/initializers/disable_email_interceptor.rb
index c76a6b8b19f..122a5829916 100644
--- a/config/initializers/disable_email_interceptor.rb
+++ b/config/initializers/disable_email_interceptor.rb
@@ -1,2 +1,4 @@
# Interceptor in lib/disable_email_interceptor.rb
-ActionMailer::Base.register_interceptor(DisableEmailInterceptor) unless Gitlab.config.gitlab.email_enabled
+unless Gitlab.config.outgoing_emails.enabled
+ ActionMailer::Base.register_interceptor(DisableEmailInterceptor)
+end
diff --git a/config/initializers/email_settings.rb b/config/initializers/email_settings.rb
new file mode 100644
index 00000000000..99cb09ebfd0
--- /dev/null
+++ b/config/initializers/email_settings.rb
@@ -0,0 +1,5 @@
+Gitlab.config.outgoing_emails.tap do |c|
+ Gitlab::Application.config.action_mailer.delivery_method = c.delivery_method
+ ActionMailer::Base.smtp_settings = c.smtp_settings.symbolize_keys
+ ActionMailer::Base.sendmail_settings = c.sendmail_settings.symbolize_keys
+end
diff --git a/config/initializers/smtp_settings.rb.sample b/config/initializers/smtp_settings.rb.sample
deleted file mode 100644
index f0fe2fdfa43..00000000000
--- a/config/initializers/smtp_settings.rb.sample
+++ /dev/null
@@ -1,22 +0,0 @@
-# To enable smtp email delivery for your GitLab instance do the following:
-# 1. Rename this file to smtp_settings.rb
-# 2. Edit settings inside this file
-# 3. Restart GitLab instance
-#
-# For full list of options and their values see http://api.rubyonrails.org/classes/ActionMailer/Base.html
-#
-
-if Rails.env.production?
- Gitlab::Application.config.action_mailer.delivery_method = :smtp
-
- ActionMailer::Base.smtp_settings = {
- address: "email.server.com",
- port: 456,
- user_name: "smtp",
- password: "123456",
- domain: "gitlab.company.com",
- authentication: :login,
- enable_starttls_auto: true,
- openssl_verify_mode: 'peer' # See ActionMailer documentation for other possible options
- }
-end