[freeside-commits] freeside/rt/lib/RT/Action SendEmail.pm, 1.1.1.6, 1.1.1.6.2.1

Ivan,,, ivan at wavetail.420.am
Mon Mar 3 15:07:49 PST 2008


Update of /home/cvs/cvsroot/freeside/rt/lib/RT/Action
In directory wavetail.420.am:/tmp/cvs-serv10370/lib/RT/Action

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	SendEmail.pm 
Log Message:
merge in rt 3.4.6.  *gulp*!

Index: SendEmail.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Action/SendEmail.pm,v
retrieving revision 1.1.1.6
retrieving revision 1.1.1.6.2.1
diff -u -d -r1.1.1.6 -r1.1.1.6.2.1
--- SendEmail.pm	17 Oct 2006 08:50:56 -0000	1.1.1.6
+++ SendEmail.pm	3 Mar 2008 23:07:46 -0000	1.1.1.6.2.1
@@ -253,12 +253,28 @@
 
     if ( $RT::MailCommand eq 'sendmailpipe' ) {
         eval {
-            open( my $mail, "|$RT::SendmailPath $RT::SendmailArguments" ) || die $!;
+            # don't ignore CHLD signal to get proper exit code
+            local $SIG{'CHLD'} = 'DEFAULT';
+
+            my $mail;
+            unless( open $mail, "|$RT::SendmailPath $RT::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);
-            close($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. -" . $@ );
+            $RT::Logger->crit( $msgid . "Could not send mail: " . $@ );
+            return 0;
         }
     }
     else {
@@ -284,13 +300,12 @@
         }
     }
 
-    my $success =
-      ( $msgid
-      . " sent To: "
-      . $MIMEObj->head->get('To') . " Cc: "
-      . $MIMEObj->head->get('Cc') . " Bcc: "
-      . $MIMEObj->head->get('Bcc') );
-    $success =~ s/\n//gi;
+    my $success = "$msgid sent";
+    foreach (qw(To Cc Bcc)) {
+        next unless my $addresses = $MIMEObj->head->get($_);
+        $success .= " $_: ". $addresses;
+    }
+    $success =~ s/\n//g;
 
     $self->RecordOutgoingMailTransaction($MIMEObj) if ($RT::RecordOutgoingEmail);
 



More information about the freeside-commits mailing list