summaryrefslogtreecommitdiffstats
path: root/lib/tasks
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-10-15 22:50:33 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-10-15 22:50:33 +0000
commit06c0e5ad1c4450013456b45f0af21de35fa894aa (patch)
tree10395546509deec2e893d6f52ed87f0062e422a2 /lib/tasks
parentc20308c7ba3204732ba2f2bac75e117c349c14d5 (diff)
downloadredmine-06c0e5ad1c4450013456b45f0af21de35fa894aa.tar.gz
redmine-06c0e5ad1c4450013456b45f0af21de35fa894aa.zip
Add rake task to send test email. (#6511)
Contributed by Holger Just git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4256 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/email.rake17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/tasks/email.rake b/lib/tasks/email.rake
index 87b5e03ce..957d9d44c 100644
--- a/lib/tasks/email.rake
+++ b/lib/tasks/email.rake
@@ -165,5 +165,22 @@ END_DESC
Redmine::POP3.check(pop_options, options)
end
+
+ desc "Send a test email to the user with the provided login name"
+ task :test, :login, :needs => :environment do |task, args|
+ include Redmine::I18n
+ abort l(:notice_email_error, "Please include the user login to test with. Example: login=examle-login") if args[:login].blank?
+
+ user = User.find_by_login(args[:login])
+ abort l(:notice_email_error, "User #{args[:login]} not found") unless user.logged?
+
+ ActionMailer::Base.raise_delivery_errors = true
+ begin
+ Mailer.deliver_test(User.current)
+ puts l(:notice_email_sent, user.mail)
+ rescue Exception => e
+ abort l(:notice_email_error, e.message)
+ end
+ end
end
end