[Rt-commit] r8772 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Tue Aug 28 14:39:24 EDT 2007


Author: ruz
Date: Tue Aug 28 14:39:24 2007
New Revision: 8772

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm

Log:
 r8681 at cubic-pc (orig r8680):  ruz | 2007-08-22 02:48:58 +0400
 * add PrepareEmailUsingTemplate function to ::Interface::Email


Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm	Tue Aug 28 14:39:24 2007
@@ -468,19 +468,17 @@
     return 1;
 }
 
-=head2 SendEmailUsingTemplate Template => '', Arguments => {}, To => '', Cc => '', Bcc => ''
+=head2 PrepareEmailUsingTemplate Template => '', Arguments => {}
 
-Sends email using a template, takes name of template, arguments for it and recipients.
+Loads a template and parses it using arguments. Returns a L<MIME::Entity>
+object or undef on errors.
 
 =cut
 
-sub SendEmailUsingTemplate {
+sub PrepareEmailUsingTemplate {
     my %args = (
         Template => '',
         Arguments => {},
-        To => undef,
-        Cc => undef,
-        Bcc => undef,
         @_
     );
 
@@ -488,12 +486,30 @@
     $template->LoadGlobalTemplate( $args{'Template'} );
     unless ( $template->id ) {
         $RT::Logger->error("Couldn't load template '". $args{'Template'} ."'");
-        return 0;
+        return (undef);
     }
     $template->Parse( %{ $args{'Arguments'} } );
 
-    my $msg = $template->MIMEObj;
-    # template parsing error
+    return $template->MIMEObj;
+}
+
+=head2 SendEmailUsingTemplate Template => '', Arguments => {}, To => '', Cc => '', Bcc => ''
+
+Sends email using a template, takes name of template, arguments for it and recipients.
+
+=cut
+
+sub SendEmailUsingTemplate {
+    my %args = (
+        Template => '',
+        Arguments => {},
+        To => undef,
+        Cc => undef,
+        Bcc => undef,
+        @_
+    );
+
+    my $msg = PrepareEmailUsingTemplate( %args );
     return 0 unless $msg;
 
     $msg->head->set( $_ => $args{ $_ } )


More information about the Rt-commit mailing list