[rt-users] Email not being sent as expected

Stephen Turner sturner at MIT.EDU
Tue Jan 3 12:19:56 EST 2006


Hello,

We're trying to track down a user report of email not being sent as 
expected by RT (3.4.2).

The ticket history shows an 'outgoing email recorded' transaction, so the 
question arose, does this mean that sendmail really sent the message?

 From the code (SendEmail.pm) it looks as though the outgoing email message 
is recorded even if the hand-off to sendmail is unsuccessful. It only does 
this if the RT::MailCommand config variable is set to 'sendmailpipe' (our 
configuration). For other mail comand options, a failure in the hand-off 
does not result in an 'outgoing email recorded' transaction.

I'm wondering why the transaction is recorded if the sendmail command fails?

Thanks,
Steve

P.S. We do not have info-level logging turned on, so we can't look at that 
to see if the mail command failed.

P.P.S. Relevant code from Send_Email.pm

     if ( $RT::MailCommand eq 'sendmailpipe' ) {
         eval {
             open( MAIL, "|$RT::SendmailPath $RT::SendmailArguments" ) || 
die $!;
             print MAIL $MIMEObj->as_string;
             close(MAIL);
         };
         if ($@) {
             $RT::Logger->crit( $msgid . "Could not send mail. -" . $@ );
         }
     }
     else {
         my @mailer_args = ($RT::MailCommand);

         local $ENV{MAILADDRESS};

         if ( $RT::MailCommand eq 'sendmail' ) {
             push @mailer_args, split(/\s+/, $RT::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);
         }
     }

     my $success =
       ( $msgid
       . " sent To: "
       . $MIMEObj->head->get('To') . " Cc: "
       . $MIMEObj->head->get('Cc') . " Bcc: "
       . $MIMEObj->head->get('Bcc') );
     $success =~ s/\n//gi;

     $self->RecordOutgoingMailTransaction($MIMEObj) if 
($RT::RecordOutgoingEmail)
;

     $RT::Logger->info($success);

     return (1);



Stephen Turner
Senior Programmer/Analyst - Client Support Services
MIT Information Services and Technology (IS&T)





More information about the rt-users mailing list