[Rt-commit] rt branch, 4.0/add-from-to-mail-error-messages, created. rt-4.0.16-50-gfd08e7e

Thomas Sibley trs at bestpractical.com
Tue Jul 30 16:41:36 EDT 2013


The branch, 4.0/add-from-to-mail-error-messages has been created
        at  fd08e7ef219917eeb6789186ab9ea3cc310d336f (commit)

- Log -----------------------------------------------------------------
commit b727acba32609725ab28d9994968c62ce67a22cd
Author: Christian Loos <cloos at netcologne.de>
Date:   Tue Jul 16 12:38:00 2013 +0200

    always log the email address to help debugging
    
    [Adjusted to use the From: header rather than $ErrorsTo, which is not
    necessarily the From: value.]
    
    Signed-off-by: Thomas Sibley <trs at bestpractical.com>

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index f259a76..e3f3c1a 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -1452,6 +1452,8 @@ sub Gateway {
 
     my $head = $Message->head;
     my $ErrorsTo = ParseErrorsToAddressFromHead( $head );
+    my $From = $head->get("From");
+    chomp $From if defined $From;
 
     my $MessageId = $head->get('Message-ID')
         || "<no-message-id-". time . rand(2000) .'@'. RT->Config->Get('Organization') .'>';
@@ -1583,7 +1585,7 @@ sub Gateway {
                 Explanation => $ErrStr,
                 MIMEObj     => $Message
             );
-            return ( 0, "Ticket creation failed: $ErrStr", $Ticket );
+            return ( 0, "Ticket creation From: $From failed: $ErrStr", $Ticket );
         }
 
         # strip comments&corresponds from the actions we don't need
@@ -1628,7 +1630,7 @@ sub Gateway {
                     Explanation => $msg,
                     MIMEObj     => $Message
                 );
-                return ( 0, "Message not recorded: $msg", $Ticket );
+                return ( 0, "Message From: $From not recorded: $msg", $Ticket );
             }
         } elsif ($unsafe_actions) {
             my ( $status, $msg ) = _RunUnsafeAction(
@@ -1727,6 +1729,8 @@ sub _RunUnsafeAction {
         @_
     );
 
+    my $From = $args{Message}->head->get("From");
+
     if ( $args{'Action'} =~ /^take$/i ) {
         my ( $status, $msg ) = $args{'Ticket'}->SetOwner( $args{'CurrentUser'}->id );
         unless ($status) {
@@ -1736,7 +1740,7 @@ sub _RunUnsafeAction {
                 Explanation => $msg,
                 MIMEObj     => $args{'Message'}
             );
-            return ( 0, "Ticket not taken" );
+            return ( 0, "Ticket not taken, by email From: $From" );
         }
     } elsif ( $args{'Action'} =~ /^resolve$/i ) {
         my $new_status = $args{'Ticket'}->FirstInactiveStatus;
@@ -1751,11 +1755,11 @@ sub _RunUnsafeAction {
                     Explanation => $msg,
                     MIMEObj     => $args{'Message'}
                 );
-                return ( 0, "Ticket not resolved" );
+                return ( 0, "Ticket not resolved, by email From: $From" );
             }
         }
     } else {
-        return ( 0, "Not supported unsafe action $args{'Action'}", $args{'Ticket'} );
+        return ( 0, "Not supported unsafe action $args{'Action'}, by email From: $From", $args{'Ticket'} );
     }
     return ( 1, "Success" );
 }

commit fd08e7ef219917eeb6789186ab9ea3cc310d336f
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Tue Jul 30 13:18:10 2013 -0700

    Log the loaded user and sender when reporting an email permission error
    
    ParseErrorsToAddressFromHead() may be misleading if the Errors-To:
    header is present (although it is unlikely to ever be).

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index e3f3c1a..b60dd0f 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -1452,6 +1452,7 @@ sub Gateway {
 
     my $head = $Message->head;
     my $ErrorsTo = ParseErrorsToAddressFromHead( $head );
+    my $Sender = (ParseSenderAddressFromHead( $head ))[0];
     my $From = $head->get("From");
     chomp $From if defined $From;
 
@@ -1538,7 +1539,8 @@ sub Gateway {
         );
         return (
             0,
-            "$ErrorsTo tried to submit a message to "
+            ($CurrentUser->EmailAddress || $CurrentUser->Name)
+            . " ($Sender) tried to submit a message to "
                 . $args{'Queue'}
                 . " without permission.",
             undef

-----------------------------------------------------------------------


More information about the Rt-commit mailing list