[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-734-g1a1f8be
Kevin Falcone
falcone at bestpractical.com
Fri Sep 10 11:09:09 EDT 2010
The branch, 3.9-trunk has been updated
via 1a1f8bedb0c6086581765e9c7f1bfeb13735d9c2 (commit)
from 9c64387174fecdfc52c8398468d928323e54c1c4 (commit)
Summary of changes:
lib/RT/Action/SendEmail.pm | 77 ++++++++++++++++++++++++++++++-------------
1 files changed, 54 insertions(+), 23 deletions(-)
- Log -----------------------------------------------------------------
commit 1a1f8bedb0c6086581765e9c7f1bfeb13735d9c2
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Tue Aug 24 18:28:31 2010 -0400
Make it easier to customize From: line in outgoing mail
Take the relatively complex FriendlyFromLine code and break it out
of the main header setting method so it is easier to extend.
diff --git a/lib/RT/Action/SendEmail.pm b/lib/RT/Action/SendEmail.pm
index c33a19a..bb8a653 100755
--- a/lib/RT/Action/SendEmail.pm
+++ b/lib/RT/Action/SendEmail.pm
@@ -864,36 +864,67 @@ sub SetReturnAddress {
}
unless ( $self->TemplateObj->MIMEObj->head->get('From') ) {
- if ( RT->Config->Get('UseFriendlyFromLine') ) {
- my $friendly_name = $args{friendly_name};
+ $self->SetFrom( %args, From => $replyto );
+ }
- unless ( $friendly_name ) {
- $friendly_name = $self->TransactionObj->CreatorObj->FriendlyName;
- if ( $friendly_name =~ /^"(.*)"$/ ) { # a quoted string
- $friendly_name = $1;
- }
- }
+ unless ( $self->TemplateObj->MIMEObj->head->get('Reply-To') ) {
+ $self->SetHeader( 'Reply-To', "$replyto" );
+ }
- $friendly_name =~ s/"/\\"/g;
- $self->SetHeader(
- 'From',
- sprintf(
- RT->Config->Get('FriendlyFromLineFormat'),
- $self->MIMEEncodeString(
- $friendly_name, RT->Config->Get('EmailOutputEncoding')
- ),
- $replyto
+}
+
+=head2 SetFrom ( From => emailaddress )
+
+Set the From: address for outgoing email
+
+=cut
+
+sub SetFrom {
+ my $self = shift;
+ my %args = @_;
+
+ if ( RT->Config->Get('UseFriendlyFromLine') ) {
+ my $friendly_name = $self->GetFriendlyName(%args);
+ $self->SetHeader(
+ 'From',
+ sprintf(
+ RT->Config->Get('FriendlyFromLineFormat'),
+ $self->MIMEEncodeString(
+ $friendly_name, RT->Config->Get('EmailOutputEncoding')
),
- );
- } else {
- $self->SetHeader( 'From', $replyto );
- }
+ $args{From}
+ ),
+ );
+ } else {
+ $self->SetHeader( 'From', $args{From} );
}
+}
- unless ( $self->TemplateObj->MIMEObj->head->get('Reply-To') ) {
- $self->SetHeader( 'Reply-To', "$replyto" );
+=head2 GetFriendlyName
+
+Calculate the proper Friendly Name based on the creator of the transaction
+
+=cut
+
+sub GetFriendlyName {
+ my $self = shift;
+ my %args = (
+ is_comment => 0,
+ friendly_name => '',
+ @_
+ );
+ my $friendly_name = $args{friendly_name};
+
+ unless ( $friendly_name ) {
+ $friendly_name = $self->TransactionObj->CreatorObj->FriendlyName;
+ if ( $friendly_name =~ /^"(.*)"$/ ) { # a quoted string
+ $friendly_name = $1;
+ }
}
+ $friendly_name =~ s/"/\\"/g;
+ return $friendly_name;
+
}
=head2 SetHeader FIELD, VALUE
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list