diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php index b655b6bb9850db8968629f9e5e713aa6a203e1c6..fb8402169e83b39c258118329215d2459d7547a2 100644 --- a/include/class.mailfetch.php +++ b/include/class.mailfetch.php @@ -147,7 +147,7 @@ class MailFetcher { return null; $list = array(); - foreach($folders as $k => $folder) + foreach($folders as $folder) $list[]= str_replace($this->srvstr, '', imap_utf7_decode(trim($folder))); return $list; @@ -211,7 +211,7 @@ class MailFetcher { $str = ''; $parts = imap_mime_header_decode($text); - foreach ($parts as $k => $part) + foreach ($parts as $part) $str.= $part->text; return $str?$str:imap_utf8($text); @@ -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()