diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-07-04 18:55:45 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-07-04 18:55:45 +0000 |
commit | fc42dd2cef3f1e43af19f6455011cdd5d298aef5 (patch) | |
tree | f5604c240760acc36eecda64e2f94fcd088a0409 /config | |
parent | 5d0b53544c859506cc7f2e52f0a5243e50bca5e9 (diff) | |
download | redmine-fc42dd2cef3f1e43af19f6455011cdd5d298aef5.tar.gz redmine-fc42dd2cef3f1e43af19f6455011cdd5d298aef5.zip |
Email delivery configuration moved to an unversioned YAML file (config/email.yml, see the sample file) (#1412).
Email delivery is disabled. It's automatically turned on when configuration is found.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1625 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'config')
-rw-r--r-- | config/email.yml.example | 21 | ||||
-rw-r--r-- | config/environment.rb | 24 | ||||
-rw-r--r-- | config/environments/test.rb | 1 | ||||
-rw-r--r-- | config/environments/test_pgsql.rb | 3 | ||||
-rw-r--r-- | config/environments/test_sqlite3.rb | 3 | ||||
-rw-r--r-- | config/initializers/40-email.rb | 17 |
6 files changed, 47 insertions, 22 deletions
diff --git a/config/email.yml.example b/config/email.yml.example new file mode 100644 index 000000000..a67c12279 --- /dev/null +++ b/config/email.yml.example @@ -0,0 +1,21 @@ +# Outgoing email settings + +production: + delivery_method: :smtp + smtp_settings: + address: smtp.somenet.foo + port: 25 + domain: somenet.foo + authentication: :login + user_name: redmine@somenet.foo + password: redmine + +development: + delivery_method: :smtp + smtp_settings: + address: 127.0.0.1 + port: 25 + domain: somenet.foo + authentication: :login + user_name: redmine@somenet.foo + password: redmine diff --git a/config/environment.rb b/config/environment.rb index b0f16c3e1..9a3bf4b1d 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -49,25 +49,9 @@ Rails::Initializer.run do |config| # Use Active Record's schema dumper instead of SQL when creating the test database # (enables use of different database adapters for development and test environments) # config.active_record.schema_format = :ruby - - # See Rails::Configuration for more options - # SMTP server configuration - config.action_mailer.smtp_settings = { - :address => "127.0.0.1", - :port => 25, - :domain => "somenet.foo", - :authentication => :login, - :user_name => "redmine@somenet.foo", - :password => "redmine", - } - - config.action_mailer.perform_deliveries = true - - # Tell ActionMailer not to deliver emails to the real world. - # The :test delivery method accumulates sent emails in the - # ActionMailer::Base.deliveries array. - #config.action_mailer.delivery_method = :test - config.action_mailer.delivery_method = :smtp - + # Deliveries are disabled by default. Do NOT modify this section. + # Define your email configuration in email.yml instead. + # It will automatically turn deliveries on + config.action_mailer.perform_deliveries = false end diff --git a/config/environments/test.rb b/config/environments/test.rb index 9ba9ae0f8..7c821da07 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -13,4 +13,5 @@ config.whiny_nils = true config.action_controller.consider_all_requests_local = true config.action_controller.perform_caching = false +config.action_mailer.perform_deliveries = true config.action_mailer.delivery_method = :test diff --git a/config/environments/test_pgsql.rb b/config/environments/test_pgsql.rb index 35bb19bee..7c821da07 100644 --- a/config/environments/test_pgsql.rb +++ b/config/environments/test_pgsql.rb @@ -13,4 +13,5 @@ config.whiny_nils = true config.action_controller.consider_all_requests_local = true config.action_controller.perform_caching = false -config.action_mailer.delivery_method = :test
\ No newline at end of file +config.action_mailer.perform_deliveries = true +config.action_mailer.delivery_method = :test diff --git a/config/environments/test_sqlite3.rb b/config/environments/test_sqlite3.rb index 35bb19bee..7c821da07 100644 --- a/config/environments/test_sqlite3.rb +++ b/config/environments/test_sqlite3.rb @@ -13,4 +13,5 @@ config.whiny_nils = true config.action_controller.consider_all_requests_local = true config.action_controller.perform_caching = false -config.action_mailer.delivery_method = :test
\ No newline at end of file +config.action_mailer.perform_deliveries = true +config.action_mailer.delivery_method = :test diff --git a/config/initializers/40-email.rb b/config/initializers/40-email.rb new file mode 100644 index 000000000..5b388ec59 --- /dev/null +++ b/config/initializers/40-email.rb @@ -0,0 +1,17 @@ +# Loads action_mailer settings from email.yml +# and turns deliveries on if configuration file is found + +filename = File.join(File.dirname(__FILE__), '..', 'email.yml') +if File.file?(filename) + mailconfig = YAML::load_file(filename) + + if mailconfig.is_a?(Hash) && mailconfig.has_key?(Rails.env) + # Enable deliveries + ActionMailer::Base.perform_deliveries = true + + mailconfig[Rails.env].each do |k, v| + v.symbolize_keys! if v.respond_to?(:symbolize_keys!) + ActionMailer::Base.send("#{k}=", v) + end + end +end |