01tonythomas has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/148456

Change subject: Notify administrators on API failing to parse bounce emails
......................................................................

Notify administrators on API failing to parse bounce emails

A bounce email, can go un-processed, even after it passed valid
VERP checks. The wiki admin needs to be notified on this event,
so that he can improve his regex functions.

Change-Id: I1c3577a9ed87f6a2656d20e319d9f66dd38d3d70
---
M ApiBounceHandler.php
M BounceHandler.php
M i18n/en.json
M i18n/qqq.json
4 files changed, 29 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BounceHandler 
refs/changes/56/148456/1

diff --git a/ApiBounceHandler.php b/ApiBounceHandler.php
index c0dc9da..b83f570 100644
--- a/ApiBounceHandler.php
+++ b/ApiBounceHandler.php
@@ -83,6 +83,7 @@
                        }
                        self::BounceHandlerActions( $wikiId, $originalEmail, 
$bounceTimestamp );
                } else {
+                       self::processUnHandledBounces( $email );
                        wfDebugLog( 'BounceHandler', "Received temporary bounce 
from $to" );
                }
 
@@ -224,4 +225,24 @@
                return true;
        }
 
+       /**
+        * Notify the system administrator about a temporary bounce which 
failed to get parsed
+        *
+        * @param string $email The received email bounce
+        */
+       public static function processUnHandledBounces( $email ) {
+               global $wgDoubleBounceNotify, $wgPasswordSender;
+               $subject = 'bouncehandler-notify_subject';
+               $sender = new MailAddress( $wgPasswordSender );
+               $to = array();
+               if ( isset( $wgDoubleBounceNotify ) ) {
+                       foreach ( $wgDoubleBounceNotify as $notifyEmails ) {
+                               $to[] = new MailAddress( $notifyEmails );
+                               UserMailer::send( $to, $sender, $subject, 
$email, $sender );
+                       }
+               }else {
+                       wfDebugLog( 'BounceHandler', " Cannot send notification 
to administrator " );
+               }
+       }
+
 }
\ No newline at end of file
diff --git a/BounceHandler.php b/BounceHandler.php
index 548d790..ad3a9f1 100644
--- a/BounceHandler.php
+++ b/BounceHandler.php
@@ -56,5 +56,8 @@
 $wgIMAPpass = 'pass';
 $wgIMAPserver = '{localhost:143/imap/novalidate-cert}INBOX';
 
-/*Allow only internal IP range to do the POST request */
+/* Allow only internal IP range to do the POST request */
 $wgBounceHandlerInternalIPs = array( '127.0.0.1', '::1' );
+
+/* Admin email address which should be notified in the case of an unprocessed 
valid bounce */
+$wgDoubleBounceNotify = array( '[email protected]' );
diff --git a/i18n/en.json b/i18n/en.json
index 0f6275b..6b567a1 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -4,5 +4,6 @@
                        "Tony Thomas"
                ]
        },
-       "bouncehandler-desc": "Helps in handling email bounces for MediaWiki"
+       "bouncehandler-desc": "Helps in handling email bounces for MediaWiki",
+    "bouncehandler-notify_subject": "Returning temporary bounce"
 }
\ No newline at end of file
diff --git a/i18n/qqq.json b/i18n/qqq.json
index d14b539..7a50a76 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -4,5 +4,6 @@
                        "Tony Thomas"
                ]
        },
-       "bouncehandler-desc": "{{desc|name=Bounce 
Handler|url=https://www.mediawiki.org/wiki/Extension:BounceHandler}}";
+       "bouncehandler-desc": "{{desc|name=Bounce 
Handler|url=https://www.mediawiki.org/wiki/Extension:BounceHandler}}";,
+    "bouncehandler-notify_subject": "Subject of notification email sent to 
wiki administrators on a failed to parse bounce"
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/148456
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1c3577a9ed87f6a2656d20e319d9f66dd38d3d70
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BounceHandler
Gerrit-Branch: master
Gerrit-Owner: 01tonythomas <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to