projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rt 4.0.23
[freeside.git]
/
rt
/
lib
/
RT
/
Action
/
SendEmail.pm
diff --git
a/rt/lib/RT/Action/SendEmail.pm
b/rt/lib/RT/Action/SendEmail.pm
index
2a7a2e3
..
af3a6bf
100755
(executable)
--- a/
rt/lib/RT/Action/SendEmail.pm
+++ b/
rt/lib/RT/Action/SendEmail.pm
@@
-2,7
+2,7
@@
#
# COPYRIGHT:
#
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-201
2
Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-201
5
Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@
-258,7
+258,7
@@
sub Bcc {
sub AddressesFromHeader {
my $self = shift;
my $field = shift;
sub AddressesFromHeader {
my $self = shift;
my $field = shift;
- my $header =
$self->TemplateObj->MIMEObj->head->get($field
);
+ my $header =
Encode::decode("UTF-8",$self->TemplateObj->MIMEObj->head->get($field)
);
my @addresses = Email::Address->parse($header);
return (@addresses);
my @addresses = Email::Address->parse($header);
return (@addresses);
@@
-277,7
+277,7
@@
sub SendMessage {
# ability to pass @_ to a 'post' routine.
my ( $self, $MIMEObj ) = @_;
# ability to pass @_ to a 'post' routine.
my ( $self, $MIMEObj ) = @_;
- my $msgid =
$MIMEObj->head->get('Message-ID'
);
+ my $msgid =
Encode::decode( "UTF-8", $MIMEObj->head->get('Message-ID')
);
chomp $msgid;
$self->ScripActionObj->{_Message_ID}++;
chomp $msgid;
$self->ScripActionObj->{_Message_ID}++;
@@
-300,7
+300,7
@@
sub SendMessage {
my $success = $msgid . " sent ";
foreach (@EMAIL_RECIPIENT_HEADERS) {
my $success = $msgid . " sent ";
foreach (@EMAIL_RECIPIENT_HEADERS) {
- my $recipients =
$MIMEObj->head->get($_
);
+ my $recipients =
Encode::decode( "UTF-8", $MIMEObj->head->get($_)
);
$success .= " $_: " . $recipients if $recipients;
}
$success .= " $_: " . $recipients if $recipients;
}
@@
-382,7
+382,7
@@
sub AddAttachments {
=head2 AddAttachment $attachment
=head2 AddAttachment $attachment
-Takes one attachment object of L<RT::Attachm
m
ent> class and attaches it to the message
+Takes one attachment object of L<RT::Attachment> class and attaches it to the message
we're building.
=cut
we're building.
=cut
@@
-397,14
+397,15
@@
sub AddAttachment {
and $attach->TransactionObj->CurrentUserCanSee;
# ->attach expects just the disposition type; extract it if we have the header
and $attach->TransactionObj->CurrentUserCanSee;
# ->attach expects just the disposition type; extract it if we have the header
+ # or default to "attachment"
my $disp = ($attach->GetHeader('Content-Disposition') || '')
my $disp = ($attach->GetHeader('Content-Disposition') || '')
- =~ /^\s*(inline|attachment)/i ? $1 :
undef
;
+ =~ /^\s*(inline|attachment)/i ? $1 :
"attachment"
;
$MIMEObj->attach(
Type => $attach->ContentType,
Charset => $attach->OriginalEncoding,
Data => $attach->OriginalContent,
$MIMEObj->attach(
Type => $attach->ContentType,
Charset => $attach->OriginalEncoding,
Data => $attach->OriginalContent,
- Disposition => $disp,
# a false value defaults to inline in MIME::Entity
+ Disposition => $disp,
Filename => $self->MIMEEncodeString( $attach->Filename ),
'RT-Attachment:' => $self->TicketObj->Id . "/"
. $self->TransactionObj->Id . "/"
Filename => $self->MIMEEncodeString( $attach->Filename ),
'RT-Attachment:' => $self->TicketObj->Id . "/"
. $self->TransactionObj->Id . "/"
@@
-530,7
+531,7
@@
sub RecordOutgoingMailTransaction {
$type = 'EmailRecord';
}
$type = 'EmailRecord';
}
- my $msgid =
$MIMEObj->head->get('Message-ID'
);
+ my $msgid =
Encode::decode( "UTF-8", $MIMEObj->head->get('Message-ID')
);
chomp $msgid;
my ( $id, $msg ) = $transaction->Create(
chomp $msgid;
my ( $id, $msg ) = $transaction->Create(
@@
-615,6
+616,7
@@
sub SetRTSpecialHeaders {
# XXX, TODO: use /ShowUser/ShowUserEntry(or something like that) when it would be
# refactored into user's method.
if ( my $email = $self->TransactionObj->CreatorObj->EmailAddress
# XXX, TODO: use /ShowUser/ShowUserEntry(or something like that) when it would be
# refactored into user's method.
if ( my $email = $self->TransactionObj->CreatorObj->EmailAddress
+ and ! defined $self->TemplateObj->MIMEObj->head->get("RT-Originator")
and RT->Config->Get('UseOriginatorHeader')
) {
$self->SetHeader( 'RT-Originator', $email );
and RT->Config->Get('UseOriginatorHeader')
) {
$self->SetHeader( 'RT-Originator', $email );
@@
-648,7
+650,7
@@
sub DeferDigestRecipients {
# Have to get the list of addresses directly from the MIME header
# at this point.
# Have to get the list of addresses directly from the MIME header
# at this point.
- $RT::Logger->debug(
$self->TemplateObj->MIMEObj->head->as_string
);
+ $RT::Logger->debug(
Encode::decode( "UTF-8", $self->TemplateObj->MIMEObj->head->as_string )
);
foreach my $rcpt ( map { $_->address } $self->AddressesFromHeader($mailfield) ) {
next unless $rcpt;
my $user_obj = RT::User->new(RT->SystemUser);
foreach my $rcpt ( map { $_->address } $self->AddressesFromHeader($mailfield) ) {
next unless $rcpt;
my $user_obj = RT::User->new(RT->SystemUser);
@@
-745,7
+747,7
@@
sub RemoveInappropriateRecipients {
# If there are no recipients, don't try to send the message.
# If the transaction has content and has the header RT-Squelch-Replies-To
# If there are no recipients, don't try to send the message.
# If the transaction has content and has the header RT-Squelch-Replies-To
- my $msgid =
$self->TemplateObj->MIMEObj->head->get('Message-Id'
);
+ my $msgid =
Encode::decode( "UTF-8", $self->TemplateObj->MIMEObj->head->get('Message-Id')
);
if ( my $attachment = $self->TransactionObj->Attachments->First ) {
if ( $attachment->GetHeader('RT-DetectedAutoGenerated') ) {
if ( my $attachment = $self->TransactionObj->Attachments->First ) {
if ( $attachment->GetHeader('RT-DetectedAutoGenerated') ) {
@@
-871,21
+873,25
@@
sub SetFrom {
my $self = shift;
my %args = @_;
my $self = shift;
my %args = @_;
+ my $from = $args{From};
+
if ( RT->Config->Get('UseFriendlyFromLine') ) {
my $friendly_name = $self->GetFriendlyName(%args);
if ( RT->Config->Get('UseFriendlyFromLine') ) {
my $friendly_name = $self->GetFriendlyName(%args);
- $self->SetHeader(
- 'From',
+ $from =
sprintf(
RT->Config->Get('FriendlyFromLineFormat'),
$self->MIMEEncodeString(
$friendly_name, RT->Config->Get('EmailOutputEncoding')
),
$args{From}
sprintf(
RT->Config->Get('FriendlyFromLineFormat'),
$self->MIMEEncodeString(
$friendly_name, RT->Config->Get('EmailOutputEncoding')
),
$args{From}
- ),
- );
- } else {
- $self->SetHeader( 'From', $args{From} );
+ );
}
}
+
+ $self->SetHeader( 'From', $from );
+
+ #also set Sender:, otherwise MTAs add a nonsensical value like rt@machine,
+ #and then Outlook prepends "rt@machine on behalf of" to the From: header
+ $self->SetHeader( 'Sender', $from );
}
=head2 GetFriendlyName
}
=head2 GetFriendlyName
@@
-917,7
+923,8
@@
sub GetFriendlyName {
=head2 SetHeader FIELD, VALUE
=head2 SetHeader FIELD, VALUE
-Set the FIELD of the current MIME object into VALUE.
+Set the FIELD of the current MIME object into VALUE, which should be in
+characters, not bytes. Returns the new header, in bytes.
=cut
=cut
@@
-930,7
+937,7
@@
sub SetHeader {
chomp $field;
my $head = $self->TemplateObj->MIMEObj->head;
$head->fold_length( $field, 10000 );
chomp $field;
my $head = $self->TemplateObj->MIMEObj->head;
$head->fold_length( $field, 10000 );
- $head->replace( $field,
$val
);
+ $head->replace( $field,
Encode::encode( "UTF-8", $val )
);
return $head->get($field);
}
return $head->get($field);
}
@@
-985,11
+992,12
@@
sub SetSubjectToken {
my $self = shift;
my $head = $self->TemplateObj->MIMEObj->head;
my $self = shift;
my $head = $self->TemplateObj->MIMEObj->head;
- $head->replace(
- Subject => RT::Interface::Email::AddSubjectTag(
- Encode::decode_utf8( $head->get('Subject') ),
- $self->TicketObj,
- ),
+ $self->SetHeader(
+ Subject =>
+ RT::Interface::Email::AddSubjectTag(
+ Encode::decode( "UTF-8", $head->get('Subject') ),
+ $self->TicketObj,
+ ),
);
}
);
}
@@
-1082,7
+1090,8
@@
sub PseudoReference {
=head2 SetHeaderAsEncoding($field_name, $charset_encoding)
=head2 SetHeaderAsEncoding($field_name, $charset_encoding)
-This routine converts the field into specified charset encoding.
+This routine converts the field into specified charset encoding, then
+applies the MIME-Header transfer encoding.
=cut
=cut
@@
-1093,12
+1102,12
@@
sub SetHeaderAsEncoding {
my $head = $self->TemplateObj->MIMEObj->head;
if ( lc($field) eq 'from' and RT->Config->Get('SMTPFrom') ) {
my $head = $self->TemplateObj->MIMEObj->head;
if ( lc($field) eq 'from' and RT->Config->Get('SMTPFrom') ) {
- $head->replace( $field,
RT->Config->Get('SMTPFrom'
) );
+ $head->replace( $field,
Encode::encode( "UTF-8", RT->Config->Get('SMTPFrom')
) );
return;
}
return;
}
- my $value =
$head->get( $field
);
- $value = $self->MIMEEncodeString( $value, $enc );
+ my $value =
Encode::decode("UTF-8", $head->get( $field )
);
+ $value = $self->MIMEEncodeString( $value, $enc );
# Returns bytes
$head->replace( $field, $value );
}
$head->replace( $field, $value );
}
@@
-1108,7
+1117,8
@@
sub SetHeaderAsEncoding {
Takes a perl string and optional encoding pass it over
L<RT::Interface::Email/EncodeToMIME>.
Takes a perl string and optional encoding pass it over
L<RT::Interface::Email/EncodeToMIME>.
-Basicly encode a string using B encoding according to RFC2047.
+Basicly encode a string using B encoding according to RFC2047, returning
+bytes.
=cut
=cut