Added 'email sending test' functionality.

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
This commit is contained in:
Jean-Philippe Lang
2007-08-14 10:36:19 +00:00
parent 7e755a53b8
commit 0061a3f04a
16 changed files with 65 additions and 6 deletions
+14
View 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
+7
View 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
+4 -3
View File
@@ -16,10 +16,11 @@
<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' %>
+1
View File
@@ -0,0 +1 @@
This is a test email sent by Redmine.