[Rt-commit] r6203 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Sat Oct 14 21:51:10 EDT 2006
Author: ruz
Date: Sat Oct 14 21:51:08 2006
New Revision: 6203
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Email.pm
Log:
r3955 at cubic-pc: cubic | 2006-10-15 03:45:11 +0400
* add more info into logs
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 Sat Oct 14 21:51:08 2006
@@ -290,47 +290,46 @@
$args{'entity'}->head->set( 'Date', $date->RFC2822( Timezone => 'server' ) );
}
- if ( RT->Config->Get('MailCommand') eq 'sendmailpipe' ) {
+ my $mail_command = RT->Config->Get('MailCommand');
+
+ if ( $mail_command eq 'sendmailpipe' ) {
my $path = RT->Config->Get('SendmailPath');
my $args = RT->Config->Get('SendmailArguments');
- $args .= RT->Config->Get('SendmailBounceArguments') if $args{bounce};
+ $args .= ' '. RT->Config->Get('SendmailBounceArguments') if $args{'bounce'};
eval {
# don't ignore CHLD signal to get proper exit code
local $SIG{'CHLD'} = 'DEFAULT';
- my $mail;
- unless( open $mail, "|$path $args" ) {
- die "Couldn't run $path: $!";
- }
+ open my $mail, "|$path $args" or die "couldn't execute program: $!";
# if something wrong with $mail->print we will get PIPE signal, handle it
- local $SIG{'PIPE'} = sub { die "$path closed pipe" };
- $args{entity}->print($mail);
+ local $SIG{'PIPE'} = sub { die "program unexpectedly closed pipe" };
+ $args{'entity'}->print($mail);
unless ( close $mail ) {
- die "Close failed: $!" if $!; # system error
+ 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_*
- $RT::Logger->warning( "$path exitted with status $?" );
+ my $msg = "`$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: " . $@ );
+ $RT::Logger->crit( "Could not send mail with command `$path $args`: " . $@ );
return 0;
}
}
else {
- my @mailer_args = (RT->Config->Get('MailCommand'));
+ local ($ENV{'MAILADDRESS'}, $ENV{'PERL_MAILERS'});
- local $ENV{MAILADDRESS};
- local $ENV{PERL_MAILERS};
-
- if ( RT->Config->Get('MailCommand') eq 'sendmail' ) {
- $ENV{PERL_MAILERS} = RT->Config->Get('SendmailPath');
+ my @mailer_args = ($mail_command);
+ if ( $mail_command eq 'sendmail' ) {
+ $ENV{'PERL_MAILERS'} = RT->Config->Get('SendmailPath');
push @mailer_args, split(/\s+/, RT->Config->Get('SendmailArguments'));
}
- elsif ( RT->Config->Get('MailCommand') eq 'smtp' ) {
- $ENV{MAILADDRESS} = RT->Config->Get('SMTPFrom') || $args{entity}->head->get('From');
+ elsif ( $mail_command eq 'smtp' ) {
+ $ENV{'MAILADDRESS'} = RT->Config->Get('SMTPFrom') || $args{'entity'}->head->get('From');
push @mailer_args, ( Server => RT->Config->Get('SMTPServer') );
push @mailer_args, ( Debug => RT->Config->Get('SMTPDebug') );
}
@@ -338,9 +337,9 @@
push @mailer_args, RT->Config->Get('MailParams');
}
- unless ( $args{entity}->send(@mailer_args) ) {
+ unless ( $args{'entity'}->send( @mailer_args ) ) {
$RT::Logger->crit( "Could not send mail." );
- return (0);
+ return 0;
}
}
return 1;
More information about the Rt-commit
mailing list