OSDN Git Service

Added 'email sending test' functionality.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 14 Aug 2007 10:36:19 +0000 (10:36 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 14 Aug 2007 10:36:19 +0000 (10:36 +0000)
Go to Admin -> Mail notifications and click on 'Send a test email'.
If an error occurs while sending the mail, the error message is displayed to the user.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@632 e93f8b46-1217-0410-a6f0-8f06a7374b81

16 files changed:
app/controllers/admin_controller.rb
app/models/mailer.rb
app/views/admin/mail_options.rhtml
app/views/mailer/test.rhtml [new file with mode: 0644]
lang/bg.yml
lang/de.yml
lang/en.yml
lang/es.yml
lang/fr.yml
lang/it.yml
lang/ja.yml
lang/nl.yml
lang/pt-br.yml
lang/pt.yml
lang/sv.yml
lang/zh.yml

index 19efb28..95d3505 100644 (file)
@@ -56,6 +56,20 @@ class AdminController < ApplicationController
     end
   end
   
+  def test_email
+    raise_delivery_errors = ActionMailer::Base.raise_delivery_errors
+    # Force ActionMailer to raise delivery errors so we can catch it
+    ActionMailer::Base.raise_delivery_errors = true
+    begin
+      @test = Mailer.deliver_test(logged_in_user)
+      flash[:notice] = l(:notice_email_sent, logged_in_user.mail)
+    rescue Exception => e
+      flash[:error] = l(:notice_email_error, e.message)
+    end
+    ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
+    redirect_to :action => 'mail_options'
+  end
+  
   def info
     @db_adapter_name = ActiveRecord::Base.connection.adapter_name
     @flags = Hash.new
index cd5925d..447feb0 100644 (file)
@@ -113,4 +113,11 @@ class Mailer < ActionMailer::Base
     @subject        = "[#{message.board.project.name} - #{message.board.name}] #{message.subject}"
     @body['message'] = message
   end
+  
+  def test(user)
+    set_language_if_valid(user.language)
+    @recipients     = user.mail
+    @from           = Setting.mail_from
+    @subject        = 'Redmine'
+  end
 end
index ef22fe5..c709657 100644 (file)
 <div class="clear"></div>
 </fieldset>
 <% end %>
-
 <br />
-<p><%= check_all_links('mail_options_form') %></p>
+<%= check_all_links('mail_options_form') %>
 </div>
 
-<%= submit_tag l(:button_save) %>
+<p><%= submit_tag l(:button_save) %></p>
 <% end %>
+
+<%= link_to l(:label_send_test_email), :action => 'test_email' %>
diff --git a/app/views/mailer/test.rhtml b/app/views/mailer/test.rhtml
new file mode 100644 (file)
index 0000000..0e1629b
--- /dev/null
@@ -0,0 +1 @@
+This is a test email sent by Redmine.
index 3afcc54..337b167 100644 (file)
@@ -69,6 +69,8 @@ notice_file_not_found: Несъществуваща или преместена
 notice_locking_conflict: Друг потребител променя тези данни в момента.
 notice_scm_error: Несъществуващ обект в склада.
 notice_not_authorized: Нямате право на достъп до тази страница.
+notice_email_sent: An email was sent to %s
+notice_email_error: An error occurred while sending mail (%s)"
 
 mail_subject_lost_password: Вашата парола
 mail_subject_register: Активация на акаунт
@@ -407,6 +409,7 @@ label_date_from: From
 label_date_to: To
 label_language_based: Language based
 label_sort_by: Sort by "%s"
+label_send_test_email: Send a test email
 
 button_login: Вход
 button_submit: Изпращане
index 9c59a1d..32ad4bc 100644 (file)
@@ -69,6 +69,8 @@ notice_file_not_found: Anhang besteht nicht oder ist gelöscht worden.
 notice_locking_conflict: Datum wurde von einem anderen Benutzer geändert.
 notice_scm_error: Eintrag und/oder Revision besteht nicht im Projektarchiv.
 notice_not_authorized: Sie sind nicht berechtigt auf diese Seite zuzugreifen.
+notice_email_sent: An email was sent to %s
+notice_email_error: An error occurred while sending mail (%s)"
 
 mail_subject_lost_password: Ihr redMine Kennwort
 mail_subject_register: redMine Kontoaktivierung
@@ -407,6 +409,7 @@ label_date_from: Von
 label_date_to: Bis
 label_language_based: Language based
 label_sort_by: Sort by "%s"
+label_send_test_email: Send a test email
 
 button_login: Einloggen
 button_submit: OK
index c144ab4..3488ee3 100644 (file)
@@ -69,6 +69,8 @@ notice_file_not_found: The page you were trying to access doesn't exist or has b
 notice_locking_conflict: Data have been updated by another user.
 notice_scm_error: Entry and/or revision doesn't exist in the repository.
 notice_not_authorized: You are not authorized to access this page.
+notice_email_sent: An email was sent to %s
+notice_email_error: An error occurred while sending mail (%s)"
 
 mail_subject_lost_password: Your redMine password
 mail_subject_register: redMine account activation
@@ -407,6 +409,7 @@ label_date_from: From
 label_date_to: To
 label_language_based: Language based
 label_sort_by: Sort by "%s"
+label_send_test_email: Send a test email
 
 button_login: Login
 button_submit: Submit
index a494fdf..26eca0b 100644 (file)
@@ -69,6 +69,8 @@ notice_file_not_found: La página que intentabas tener acceso no existe ni se ha
 notice_locking_conflict: Data have been updated by another user.
 notice_scm_error: La entrada y/o la revisión no existe en el depósito.
 notice_not_authorized: You are not authorized to access this page.
+notice_email_sent: An email was sent to %s
+notice_email_error: An error occurred while sending mail (%s)"
 
 mail_subject_lost_password: Tu contraseña del redMine
 mail_subject_register: Activación de la cuenta del redMine
@@ -407,6 +409,7 @@ label_date_from: From
 label_date_to: To
 label_language_based: Language based
 label_sort_by: Sort by "%s"
+label_send_test_email: Send a test email
 
 button_login: Conexión
 button_submit: Someter
index e0b6669..3643597 100644 (file)
@@ -65,10 +65,12 @@ notice_successful_create: Création effectuée avec succès.
 notice_successful_update: Mise à jour effectuée avec succès.
 notice_successful_delete: Suppression effectuée avec succès.
 notice_successful_connection: Connection réussie.
-notice_file_not_found: La page à laquelle vous souhaitez accéder n'existe pas ou a été supprimée.
+notice_file_not_found: "La page à laquelle vous souhaitez accéder n'existe pas ou a été supprimée."
 notice_locking_conflict: Les données ont été mises à jour par un autre utilisateur. Mise à jour impossible.
-notice_scm_error: L'entrée et/ou la révision demandée n'existe pas dans le dépôt.
-notice_not_authorized: Vous n'êtes pas autorisés à accéder à cette page.
+notice_scm_error: "L'entrée et/ou la révision demandée n'existe pas dans le dépôt."
+notice_not_authorized: "Vous n'êtes pas autorisés à accéder à cette page."
+notice_email_sent: "Un email a été envoyé à %s"
+notice_email_error: "Erreur lors de l'envoi de l'email (%s)"
 
 mail_subject_lost_password: Votre mot de passe redMine
 mail_subject_register: Activation de votre compte redMine
@@ -407,6 +409,7 @@ label_date_from: Du
 label_date_to: Au
 label_language_based: Basé sur la langue
 label_sort_by: Trier par "%s"
+label_send_test_email: Envoyer un email de test
 
 button_login: Connexion
 button_submit: Soumettre
index 5cc81a6..d3f04b9 100644 (file)
@@ -69,6 +69,8 @@ notice_file_not_found: La pagina desiderata non esiste o è stata rimossa.
 notice_locking_conflict: Le informazioni sono state modificate da un altro utente.
 notice_scm_error: La risorsa e/o la versione non esistono nel repository.
 notice_not_authorized: You are not authorized to access this page.
+notice_email_sent: An email was sent to %s
+notice_email_error: An error occurred while sending mail (%s)"
 
 mail_subject_lost_password: Password redMine
 mail_subject_register: Attivazione utenza redMine
@@ -407,6 +409,7 @@ label_date_from: From
 label_date_to: To
 label_language_based: Language based
 label_sort_by: Sort by "%s"
+label_send_test_email: Send a test email
 
 button_login: Login
 button_submit: Invia
index 34a1bbe..703652b 100644 (file)
@@ -70,6 +70,8 @@ notice_file_not_found: アクセスしようとしたページは存在しない
 notice_locking_conflict: 別のユーザがデータを更新しています。
 notice_scm_error: リポジトリに、エントリ/リビジョンが存在しません。
 notice_not_authorized: このページにアクセスするには認証が必要です。
+notice_email_sent: An email was sent to %s
+notice_email_error: An error occurred while sending mail (%s)"
 
 mail_subject_lost_password: redMineパスワード
 mail_subject_register: redMineアカウントが有効になりました
@@ -408,6 +410,7 @@ label_date_from: From
 label_date_to: To
 label_language_based: Language based
 label_sort_by: Sort by "%s"
+label_send_test_email: Send a test email
 
 button_login: ログイン
 button_submit: 変更
index 99ea5b3..29b7751 100644 (file)
@@ -69,6 +69,8 @@ notice_file_not_found: De pagina die U probeerde te benaderen bestaat niet of is
 notice_locking_conflict: De gegevens zijn gewijzigd door een andere gebruiker.
 notice_scm_error: Deze ingang of revisie bestaat niet in de repository.
 notice_not_authorized: Het is U niet toegestaan om deze pagina te raadplegen.
+notice_email_sent: An email was sent to %s
+notice_email_error: An error occurred while sending mail (%s)"
 
 mail_subject_lost_password: Uw redMine wachtwoord
 mail_subject_register: redMine account activatie
@@ -407,6 +409,7 @@ label_date_from: From
 label_date_to: To
 label_language_based: Language based
 label_sort_by: Sort by "%s"
+label_send_test_email: Send a test email
 
 button_login: Inloggen
 button_submit: Toevoegen
index 6043c8b..7196db8 100644 (file)
@@ -69,6 +69,8 @@ notice_file_not_found: A pagina que voce esta tentando acessar nao existe ou foi
 notice_locking_conflict: Os dados foram atualizados por um outro usuario.\r
 notice_scm_error: A entrada e/ou a revisao nao existem no repositorio.\r
 notice_not_authorized: You are not authorized to access this page.\r
+notice_email_sent: An email was sent to %s\r
+notice_email_error: An error occurred while sending mail (%s)"\r
 \r
 mail_subject_lost_password: Sua senha do redMine.\r
 mail_subject_register: Ativacao de conta do redMine.\r
@@ -407,6 +409,7 @@ label_date_from: From
 label_date_to: To\r
 label_language_based: Language based\r
 label_sort_by: Sort by "%s"\r
+label_send_test_email: Send a test email\r
 \r
 button_login: Login\r
 button_submit: Enviar\r
index 6b137cd..face383 100644 (file)
@@ -69,6 +69,8 @@ notice_file_not_found: A página que você está tentando acessar não existe ou
 notice_locking_conflict: Os dados foram atualizados por um outro usuário.
 notice_scm_error: A entrada e/ou a revisão não existem no repositório.
 notice_not_authorized: Você não está autorizado a acessar esta página.
+notice_email_sent: An email was sent to %s
+notice_email_error: An error occurred while sending mail (%s)"
 
 mail_subject_lost_password: Sua senha do redMine.
 mail_subject_register: Ativação de conta do redMine.
@@ -407,6 +409,7 @@ label_date_from: From
 label_date_to: To
 label_language_based: Language based
 label_sort_by: Sort by "%s"
+label_send_test_email: Send a test email
 
 button_login: Login
 button_submit: Enviar
index 8f48240..70cb15c 100644 (file)
@@ -69,6 +69,8 @@ notice_file_not_found: Sidan du försökte komma åt existerar inte eller har bl
 notice_locking_conflict: Data har uppdaterats av en annan användare.
 notice_scm_error: Inlägg och/eller revision finns inte i repositoriet.
 notice_not_authorized: You are not authorized to access this page.
+notice_email_sent: An email was sent to %s
+notice_email_error: An error occurred while sending mail (%s)"
 
 mail_subject_lost_password: Ditt redMine lösenord
 mail_subject_register: redMine kontoaktivering
@@ -407,6 +409,7 @@ label_date_from: From
 label_date_to: To
 label_language_based: Language based
 label_sort_by: Sort by "%s"
+label_send_test_email: Send a test email
 
 button_login: Logga in
 button_submit: Skicka
index 043aad1..de8cfdb 100644 (file)
@@ -72,6 +72,8 @@ notice_file_not_found: 您访问的页面不存在或已被删除。
 notice_locking_conflict: 数据已被另一个用户更新
 notice_scm_error: 在版本库中不存在该条目或修订
 notice_not_authorized: You are not authorized to access this page.
+notice_email_sent: An email was sent to %s
+notice_email_error: An error occurred while sending mail (%s)"
 
 mail_subject_lost_password: 您的redMine口令
 mail_subject_register: redMine帐户激活
@@ -409,6 +411,7 @@ label_date_from: From
 label_date_to: To
 label_language_based: Language based
 label_sort_by: Sort by "%s"
+label_send_test_email: Send a test email
 
 button_login: 登录
 button_submit: 提交