]> source.dussan.org Git - redmine.git/commitdiff
Add rake task to send test email. (#6511)
authorEric Davis <edavis@littlestreamsoftware.com>
Fri, 15 Oct 2010 22:50:33 +0000 (22:50 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Fri, 15 Oct 2010 22:50:33 +0000 (22:50 +0000)
Contributed by Holger Just

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4256 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/tasks/email.rake

index 87b5e03ce0626f9e2b84cba78a0903f9651870cd..957d9d44c044d43cee2b79be10cec184d2425fa7 100644 (file)
@@ -165,5 +165,22 @@ END_DESC
       \r
       Redmine::POP3.check(pop_options, options)\r
     end\r
+    \r
+    desc "Send a test email to the user with the provided login name"\r
+    task :test, :login, :needs => :environment do |task, args|\r
+      include Redmine::I18n\r
+      abort l(:notice_email_error, "Please include the user login to test with. Example: login=examle-login") if args[:login].blank?\r
+\r
+      user = User.find_by_login(args[:login])\r
+      abort l(:notice_email_error, "User #{args[:login]} not found") unless user.logged?\r
+      \r
+      ActionMailer::Base.raise_delivery_errors = true\r
+      begin\r
+        Mailer.deliver_test(User.current)\r
+        puts l(:notice_email_sent, user.mail)\r
+      rescue Exception => e\r
+        abort l(:notice_email_error, e.message)\r
+      end\r
+    end\r
   end\r
 end\r