[Rt-commit] r6605 - in
rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/lib/RT: Action
ruz at bestpractical.com
ruz at bestpractical.com
Fri Dec 8 22:12:37 EST 2006
Author: ruz
Date: Fri Dec 8 22:12:36 2006
New Revision: 6605
Modified:
rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/lib/RT/Action/SendEmail.pm
rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/lib/RT/Interface/Email.pm
Log:
* merge functions back together as it was before merge
Modified: rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/lib/RT/Action/SendEmail.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/lib/RT/Action/SendEmail.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/lib/RT/Action/SendEmail.pm Fri Dec 8 22:12:36 2006
@@ -101,9 +101,8 @@
my $self = shift;
my $ret = $self->SendMessage( $self->TemplateObj->MIMEObj );
- if ($ret) {
+ if ( $ret && RT->Config->Get('RecordOutgoingEmail') ) {
$self->RecordOutgoingMailTransaction( $self->TemplateObj->MIMEObj )
- if ($RT::RecordOutgoingEmail);
}
return ($ret);
}
@@ -255,7 +254,10 @@
return (1);
}
- return(0) unless RT::Interface::Email::SendEmail( entity => $MIMEObj );
+ return(0) unless RT::Interface::Email::SendEmail(
+ entity => $MIMEObj,
+ transaction => $self->TransactionObj,
+ );
my $success = $msgid . " sent ";
foreach( qw(To Cc Bcc) ) {
@@ -269,84 +271,6 @@
return (1);
}
-
-=head2 OutputMIMEObject MIME::Entity
-
-Sends C<MIME::Entity> as an email message according to RT's mailer configuration.
-
-=cut
-
-
-
-sub OutputMIMEObject {
- my $self = shift;
- my $MIMEObj = shift;
-
- my $msgid = $MIMEObj->head->get('Message-ID');
- chomp $msgid;
-
- my $SendmailArguments = $RT::SendmailArguments;
- if (defined $RT::VERPPrefix && defined $RT::VERPDomain) {
- my $EnvelopeFrom = $self->TransactionObj->CreatorObj->EmailAddress;
- $EnvelopeFrom =~ s/@/=/g;
- $EnvelopeFrom =~ s/\s//g;
- $SendmailArguments .= " -f ${RT::VERPPrefix}${EnvelopeFrom}\@${RT::VERPDomain}";
- }
-
-
- if ( $RT::MailCommand eq 'sendmailpipe' ) {
- eval {
- # don't ignore CHLD signal to get proper exit code
- local $SIG{'CHLD'} = 'DEFAULT';
-
- my $mail;
- unless( open $mail, "|$RT::SendmailPath $SendmailArguments" ) {
- die "Couldn't run $RT::SendmailPath: $!";
- }
-
- # if something wrong with $mail->print we will get PIPE signal, handle it
- local $SIG{'PIPE'} = sub { die "$RT::SendmailPath closed pipe" };
- $MIMEObj->print($mail);
-
- unless ( close $mail ) {
- die "Close failed: $!" if $!; # system error
- # sendmail exit statuses mostly errors with data not software
- # TODO: status parsing: core dump, exit on signal or EX_*
- $RT::Logger->warning( "$RT::SendmailPath exitted with status $?" );
- }
- };
- if ($@) {
- $RT::Logger->crit( $msgid . "Could not send mail: " . $@ );
- return 0;
- }
- }
- else {
- my @mailer_args = ($RT::MailCommand);
-
- local $ENV{MAILADDRESS};
-
- if ( $RT::MailCommand eq 'sendmail' ) {
- push @mailer_args, split(/\s+/, $SendmailArguments);
- }
- elsif ( $RT::MailCommand eq 'smtp' ) {
- $ENV{MAILADDRESS} = $RT::SMTPFrom || $MIMEObj->head->get('From');
- push @mailer_args, ( Server => $RT::SMTPServer );
- push @mailer_args, ( Debug => $RT::SMTPDebug );
- }
- else {
- push @mailer_args, $RT::MailParams;
- }
-
- unless ( $MIMEObj->send(@mailer_args) ) {
- $RT::Logger->crit( $msgid . "Could not send mail." );
- return (0);
- }
- }
- return 1;
-}
-
-# }}}
-
# {{{ AddAttachments
=head2 AddAttachments
Modified: rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/lib/RT/Interface/Email.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL-RTIR-2.2/lib/RT/Interface/Email.pm Fri Dec 8 22:12:36 2006
@@ -284,6 +284,10 @@
$RT::Logger->crit( "Could not send mail without 'entity' object" );
return 0;
}
+
+ my $msgid = $args{'entity'}->head->get('Message-ID') || '';
+ chomp $msgid;
+
unless ( $args{'entity'}->head->get('Date') ) {
require RT::Date;
my $date = RT::Date->new( $RT::SystemUser );
@@ -297,6 +301,18 @@
my $path = RT->Config->Get('SendmailPath');
my $args = RT->Config->Get('SendmailArguments');
$args .= ' '. RT->Config->Get('SendmailBounceArguments') if $args{'bounce'};
+
+ # VERP
+ if ( $args{'transaction'} and
+ my $prefix = RT->Config->Get('VERPPrefix') and
+ my $domain = RT->Config->Get('VERPDomain') )
+ {
+ my $from = $args{'transaction'}->CreatorObj->EmailAddress;
+ $from =~ s/@/=/g;
+ $from =~ s/\s//g;
+ $args .= " -f $prefix$from\@$domain";
+ }
+
eval {
# don't ignore CHLD signal to get proper exit code
local $SIG{'CHLD'} = 'DEFAULT';
@@ -311,13 +327,13 @@
die "close pipe failed: $!" if $!; # system error
# sendmail exit statuses mostly errors with data not software
# TODO: status parsing: core dump, exit on signal or EX_*
- my $msg = "`$path $args` exitted with code ". ($?>>8);
+ my $msg = "$msgid: `$path $args` exitted with code ". ($?>>8);
$msg = ", interrupted by signal ". ($?&127) if $?&127;
$RT::Logger->error( $msg );
}
};
if ( $@ ) {
- $RT::Logger->crit( "Could not send mail with command `$path $args`: " . $@ );
+ $RT::Logger->crit( "$msgid: Could not send mail with command `$path $args`: " . $@ );
return 0;
}
}
@@ -339,7 +355,7 @@
}
unless ( $args{'entity'}->send( @mailer_args ) ) {
- $RT::Logger->crit( "Could not send mail." );
+ $RT::Logger->crit( "$msgid: Could not send mail." );
return 0;
}
}
More information about the Rt-commit
mailing list