[Rt-commit] r8680 -
rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface
ruz at bestpractical.com
ruz at bestpractical.com
Tue Aug 21 18:48:58 EDT 2007
Author: ruz
Date: Tue Aug 21 18:48:58 2007
New Revision: 8680
Modified:
rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Email.pm
Log:
* add PrepareEmailUsingTemplate function to ::Interface::Email
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Email.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Email.pm Tue Aug 21 18:48:58 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