summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-04 18:55:45 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-07-04 18:55:45 +0000
commitfc42dd2cef3f1e43af19f6455011cdd5d298aef5 (patch)
treef5604c240760acc36eecda64e2f94fcd088a0409
parent5d0b53544c859506cc7f2e52f0a5243e50bca5e9 (diff)
downloadredmine-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
-rw-r--r--app/controllers/settings_controller.rb1
-rw-r--r--app/views/settings/_notifications.rhtml6
-rw-r--r--config/email.yml.example21
-rw-r--r--config/environment.rb24
-rw-r--r--config/environments/test.rb1
-rw-r--r--config/environments/test_pgsql.rb3
-rw-r--r--config/environments/test_sqlite3.rb3
-rw-r--r--config/initializers/40-email.rb17
-rw-r--r--doc/INSTALL10
-rw-r--r--doc/UPGRADING8
-rw-r--r--lang/bg.yml1
-rw-r--r--lang/cs.yml1
-rw-r--r--lang/da.yml1
-rw-r--r--lang/de.yml1
-rw-r--r--lang/en.yml1
-rw-r--r--lang/es.yml1
-rw-r--r--lang/fi.yml1
-rw-r--r--lang/fr.yml1
-rw-r--r--lang/he.yml1
-rw-r--r--lang/hu.yml1
-rw-r--r--lang/it.yml1
-rw-r--r--lang/ja.yml1
-rw-r--r--lang/ko.yml1
-rw-r--r--lang/lt.yml1
-rw-r--r--lang/nl.yml1
-rw-r--r--lang/no.yml1
-rw-r--r--lang/pl.yml1
-rw-r--r--lang/pt-br.yml1
-rw-r--r--lang/pt.yml1
-rw-r--r--lang/ro.yml1
-rw-r--r--lang/ru.yml1
-rw-r--r--lang/sr.yml1
-rw-r--r--lang/sv.yml1
-rw-r--r--lang/th.yml1
-rw-r--r--lang/uk.yml1
-rw-r--r--lang/zh-tw.yml1
-rw-r--r--lang/zh.yml1
37 files changed, 89 insertions, 32 deletions
diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb
index c7c8751dd..59b9c67e1 100644
--- a/app/controllers/settings_controller.rb
+++ b/app/controllers/settings_controller.rb
@@ -39,6 +39,7 @@ class SettingsController < ApplicationController
end
@options = {}
@options[:user_format] = User::USER_FORMATS.keys.collect {|f| [User.current.name(f), f.to_s] }
+ @deliveries = ActionMailer::Base.perform_deliveries
end
def plugin
diff --git a/app/views/settings/_notifications.rhtml b/app/views/settings/_notifications.rhtml
index 1a472d606..36701463a 100644
--- a/app/views/settings/_notifications.rhtml
+++ b/app/views/settings/_notifications.rhtml
@@ -1,3 +1,4 @@
+<% if @deliveries %>
<% form_tag({:action => 'edit', :tab => 'notifications'}) do %>
<div class="box tabular settings">
@@ -28,3 +29,8 @@
<%= submit_tag l(:button_save) %>
<% end %>
+<% else %>
+<div class="nodata">
+<%= simple_format(l(:text_email_delivery_not_configured)) %>
+</div>
+<% end %>
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
diff --git a/doc/INSTALL b/doc/INSTALL
index 87a2b38d5..13502f8d0 100644
--- a/doc/INSTALL
+++ b/doc/INSTALL
@@ -53,10 +53,10 @@ Optional:
trackers, statuses, workflow) and adjust application settings
-== SMTP server Configuration
-
-In config/environment.rb, you can set parameters for your SMTP server:
-config.action_mailer.smtp_settings: SMTP server configuration
-config.action_mailer.perform_deliveries: set to false to disable mail delivering
+== Email delivery Configuration
+Copy config/email.yml.example to config/email.yml and edit this file
+to adjust your SMTP settings.
Don't forget to restart the application after any change to this file.
+
+Please do not enter your SMTP settings in environment.rb.
diff --git a/doc/UPGRADING b/doc/UPGRADING
index 2edb2952a..1dd901171 100644
--- a/doc/UPGRADING
+++ b/doc/UPGRADING
@@ -10,15 +10,13 @@ http://www.redmine.org/
1. Uncompress the program archive in a new directory
3. Copy your database settings (RAILS_ROOT/config/database.yml)
+ and SMTP settings (RAILS_ROOT/config/email.yml)
into the new config directory
-4. Enter your SMTP settings in config/environment.rb
- Do not replace this file with the old one
-
-5. Migrate your database (please make a backup before doing this):
+4. Migrate your database (please make a backup before doing this):
rake db:migrate RAILS_ENV="production"
-6. Copy the RAILS_ROOT/files directory content into your new installation
+5. Copy the RAILS_ROOT/files directory content into your new installation
This directory contains all the attached files
diff --git a/lang/bg.yml b/lang/bg.yml
index fd6e7e6cf..c87e3bebc 100644
--- a/lang/bg.yml
+++ b/lang/bg.yml
@@ -631,3 +631,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/cs.yml b/lang/cs.yml
index 2c760722b..6669c6cf3 100644
--- a/lang/cs.yml
+++ b/lang/cs.yml
@@ -636,3 +636,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/da.yml b/lang/da.yml
index d51d30817..cf40e1763 100644
--- a/lang/da.yml
+++ b/lang/da.yml
@@ -633,3 +633,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/de.yml b/lang/de.yml
index 2bc0a16f7..adc3dd4e9 100644
--- a/lang/de.yml
+++ b/lang/de.yml
@@ -632,3 +632,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/en.yml b/lang/en.yml
index 180a70565..791094674 100644
--- a/lang/en.yml
+++ b/lang/en.yml
@@ -606,6 +606,7 @@ text_reassign_time_entries: 'Reassign reported hours to this issue:'
text_user_wrote: '%s wrote:'
text_enumeration_destroy_question: '%d objects are assigned to this value.'
text_enumeration_category_reassign_to: 'Reassign them to this value:'
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
default_role_manager: Manager
default_role_developper: Developer
diff --git a/lang/es.yml b/lang/es.yml
index 44d48190b..4205402e4 100644
--- a/lang/es.yml
+++ b/lang/es.yml
@@ -634,3 +634,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/fi.yml b/lang/fi.yml
index 27f3415c6..b69b07557 100644
--- a/lang/fi.yml
+++ b/lang/fi.yml
@@ -631,3 +631,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/fr.yml b/lang/fr.yml
index 89b0b4c86..5b0f04fb0 100644
--- a/lang/fr.yml
+++ b/lang/fr.yml
@@ -606,6 +606,7 @@ text_reassign_time_entries: 'Reporter les heures sur cette demande:'
text_user_wrote: '%s a écrit:'
text_enumeration_destroy_question: 'Cette valeur est affectée à %d objets.'
text_enumeration_category_reassign_to: 'Réaffecter les objets à cette valeur:'
+text_email_delivery_not_configured: "L'envoi de mail n'est pas configuré, les notifications sont désactivées.\nConfigurez votre serveur SMTP dans config/email.yml et redémarrez l'application pour les activer."
default_role_manager: Manager
default_role_developper: Développeur
diff --git a/lang/he.yml b/lang/he.yml
index 501cfdc9b..030e09dcc 100644
--- a/lang/he.yml
+++ b/lang/he.yml
@@ -631,3 +631,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/hu.yml b/lang/hu.yml
index 6f88eb962..046916b7a 100644
--- a/lang/hu.yml
+++ b/lang/hu.yml
@@ -632,3 +632,4 @@ label_incoming_emails: Beérkezett levelek
label_generate_key: Kulcs generálása
setting_mail_handler_api_enabled: Web Service engedélyezése a beérkezett levelekhez
setting_mail_handler_api_key: API kulcs
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/it.yml b/lang/it.yml
index 14dc86fff..eb835400e 100644
--- a/lang/it.yml
+++ b/lang/it.yml
@@ -631,3 +631,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/ja.yml b/lang/ja.yml
index 5bdc3b554..cba410f6d 100644
--- a/lang/ja.yml
+++ b/lang/ja.yml
@@ -632,3 +632,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/ko.yml b/lang/ko.yml
index 8e0d35ef4..2b5b0eb0a 100644
--- a/lang/ko.yml
+++ b/lang/ko.yml
@@ -631,3 +631,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/lt.yml b/lang/lt.yml
index 0f80a94d8..52b6b6fc8 100644
--- a/lang/lt.yml
+++ b/lang/lt.yml
@@ -634,3 +634,4 @@ label_generate_key: Generuoti raktą
setting_mail_handler_api_enabled: Įgalinti WS įeinantiems laiškams
setting_mail_handler_api_key: API raktas
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/nl.yml b/lang/nl.yml
index d1facc7a6..09cdc3c08 100644
--- a/lang/nl.yml
+++ b/lang/nl.yml
@@ -632,3 +632,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/no.yml b/lang/no.yml
index bf25a15a5..eb1ff59ca 100644
--- a/lang/no.yml
+++ b/lang/no.yml
@@ -632,3 +632,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/pl.yml b/lang/pl.yml
index 28c5f19d4..9c5a382b0 100644
--- a/lang/pl.yml
+++ b/lang/pl.yml
@@ -631,3 +631,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/pt-br.yml b/lang/pt-br.yml
index 04c3b347c..1582e568f 100644
--- a/lang/pt-br.yml
+++ b/lang/pt-br.yml
@@ -631,3 +631,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/pt.yml b/lang/pt.yml
index 5a1ffc2e0..a5b703fcf 100644
--- a/lang/pt.yml
+++ b/lang/pt.yml
@@ -631,3 +631,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/ro.yml b/lang/ro.yml
index 3a1696c7b..3fa154d48 100644
--- a/lang/ro.yml
+++ b/lang/ro.yml
@@ -631,3 +631,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/ru.yml b/lang/ru.yml
index 7d0707f7f..5d59ec1fb 100644
--- a/lang/ru.yml
+++ b/lang/ru.yml
@@ -635,3 +635,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/sr.yml b/lang/sr.yml
index 5b8e5d934..fa1b4d847 100644
--- a/lang/sr.yml
+++ b/lang/sr.yml
@@ -632,3 +632,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/sv.yml b/lang/sv.yml
index 4c6170f4a..9015099e7 100644
--- a/lang/sv.yml
+++ b/lang/sv.yml
@@ -632,3 +632,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/th.yml b/lang/th.yml
index e7f276a34..27f7b14cf 100644
--- a/lang/th.yml
+++ b/lang/th.yml
@@ -634,3 +634,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/uk.yml b/lang/uk.yml
index 275de0e4b..0286779be 100644
--- a/lang/uk.yml
+++ b/lang/uk.yml
@@ -633,3 +633,4 @@ label_incoming_emails: Incoming emails
label_generate_key: Generate a key
setting_mail_handler_api_enabled: Enable WS for incoming emails
setting_mail_handler_api_key: API key
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/zh-tw.yml b/lang/zh-tw.yml
index 9b43ed45e..0e8fabef9 100644
--- a/lang/zh-tw.yml
+++ b/lang/zh-tw.yml
@@ -632,3 +632,4 @@ default_activity_development: 開發
enumeration_issue_priorities: 項目優先權
enumeration_doc_categories: 文件分類
enumeration_activities: 活動 (時間追蹤)
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."
diff --git a/lang/zh.yml b/lang/zh.yml
index 2bd0880a5..1cde9f502 100644
--- a/lang/zh.yml
+++ b/lang/zh.yml
@@ -632,3 +632,4 @@ default_activity_development: 开发
enumeration_issue_priorities: 问题优先级
enumeration_doc_categories: 文档类别
enumeration_activities: 活动(时间跟踪)
+text_email_delivery_not_configured: "Email delivery is not configured, and notifications are disabled.\nConfigure your SMTP server in config/email.yml and restart the application to enable them."