From 7cb48fc4d4b6b36edd40e1ec46f59c65a78aca34 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Mon, 30 Jul 2012 14:22:44 -0400
Subject: [PATCH] Log warning on excessive errors

---
 include/class.mailfetch.php | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php
index 6ff13ca97..fb8402169 100644
--- a/include/class.mailfetch.php
+++ b/include/class.mailfetch.php
@@ -478,15 +478,26 @@ class MailFetcher {
                 $errors++;
             }
 
-            if(($max && $msgs>=$max) || $errors>100)
+            if($max && ($msgs>=$max || $errors>($max*0.8)))
                 break;
         }
 
+        //Warn on excessive errors
+        if($errors>$msgs) {
+            $warn=sprintf('Excessive errors processing emails for %s/%s. Please manually check the inbox.',
+                    $this->getHost(), $this->getUsername());
+            $this->log($warn);
+        }
+
         @imap_expunge($this->mbox);
 
         return $msgs;
     }
 
+    function log($error) {
+        global $ost;
+        $ost->logWarning('Mail Fetcher', $error);
+    }
 
     /*
        MailFetcher::run()
-- 
GitLab