[Rt-commit] r4074 - in rt/branches/3.4-RELEASE: . etc lib/RT/Interface

alexmv at bestpractical.com alexmv at bestpractical.com
Mon Nov 14 13:52:01 EST 2005


Author: alexmv
Date: Mon Nov 14 13:52:00 2005
New Revision: 4074

Modified:
   rt/branches/3.4-RELEASE/   (props changed)
   rt/branches/3.4-RELEASE/etc/RT_Config.pm.in
   rt/branches/3.4-RELEASE/lib/RT/Interface/Email.pm
Log:
 r7140 at zoq-fot-pik:  chmrr | 2005-11-14 13:51:14 -0500
  * Better bounce handling, from Abhijit Menon-Sen <ams at oryx.com>


Modified: rt/branches/3.4-RELEASE/etc/RT_Config.pm.in
==============================================================================
--- rt/branches/3.4-RELEASE/etc/RT_Config.pm.in	(original)
+++ rt/branches/3.4-RELEASE/etc/RT_Config.pm.in	Mon Nov 14 13:52:00 2005
@@ -210,6 +210,11 @@
 # These options are good for most sendmail wrappers and workalikes
 Set($SendmailArguments , "-oi -t");
 
+# $SendmailBounceArguments defines what flags to pass to $Sendmail
+# assuming RT needs to send an error (ie. bounce).
+
+Set($SendmailBounceArguments , '-f "<>"');
+
 # These arguments are good for sendmail brand sendmail 8 and newer
 #Set($SendmailArguments,"-oi -t -ODeliveryMode=b -OErrorMode=m");
 

Modified: rt/branches/3.4-RELEASE/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Interface/Email.pm	(original)
+++ rt/branches/3.4-RELEASE/lib/RT/Interface/Email.pm	Mon Nov 14 13:52:00 2005
@@ -68,6 +68,7 @@
               &CheckForLoops 
               &CheckForSuspiciousSender
               &CheckForAutoGenerated 
+              &CheckForBounce 
               &MailError 
               &ParseCcAddressesFromHead
               &ParseSenderAddressFromHead 
@@ -171,6 +172,16 @@
 
 # }}}
 
+# {{{ sub CheckForBounce
+sub CheckForBounce {
+    my $head = shift;
+   
+    my $ReturnPath = $head->get("Return-path") || "" ;
+    return ($ReturnPath =~ /<>/);
+}
+
+# }}}
+
 # {{{ IsRTAddress
 
 =head2 IsRTAddress ADDRESS
@@ -250,7 +261,7 @@
     }
 
     if ($RT::MailCommand eq 'sendmailpipe') {
-        open (MAIL, "|$RT::SendmailPath $RT::SendmailArguments") || return(0);
+        open (MAIL, "|$RT::SendmailPath $RT::SendmailBounceArguments $RT::SendmailArguments") || return(0);
         print MAIL $entity->as_string;
         close(MAIL);
     }
@@ -378,7 +389,8 @@
 =head2 ParseErrorsToAddressFromHead
 
 Takes a MIME::Header object. Return a single value : user at host
-of the From (evaluated in order of Errors-To:,Reply-To:, From:, Sender)
+of the From (evaluated in order of Return-path:,Errors-To:,Reply-To:,
+From:, Sender)
 
 =cut
 
@@ -386,7 +398,7 @@
     my $head = shift;
     #Figure out who's sending this message.
 
-    foreach my $header ('Errors-To' , 'Reply-To', 'From', 'Sender' ) {
+    foreach my $header ('Return-path', 'Errors-To' , 'Reply-To', 'From', 'Sender' ) {
 	# If there's a header of that name
 	my $headerobj = $head->get($header);
 	if ($headerobj) {
@@ -655,6 +667,8 @@
     # }}}
 
     # {{{ Lets check for mail loops of various sorts.
+    my $IsBounce = CheckForBounce($head);
+
     my $IsAutoGenerated = CheckForAutoGenerated($head);
 
     my $IsSuspiciousSender = CheckForSuspiciousSender($head);
@@ -665,7 +679,7 @@
 
     #If the message is autogenerated, we need to know, so we can not
     # send mail to the sender
-    if ( $IsSuspiciousSender || $IsAutoGenerated || $IsALoop ) {
+    if ( $IsBounce || $IsSuspiciousSender || $IsAutoGenerated || $IsALoop ) {
         $SquelchReplies = 1;
         $ErrorsTo       = $RT::OwnerEmail;
     }


More information about the Rt-commit mailing list