function processMessages($link, $max = 3000) { global $bounce_mailbox_purge_unprocessed, $bounce_mailbox_purge; $num = imap_num_msg($link); outputProcessBounce($num . " " . $GLOBALS['I18N']->get("bounces to fetch from the mailbox") . "\n"); outputProcessBounce($GLOBALS['I18N']->get("Please do not interrupt this process") . "\n"); $report = $num . " " . $GLOBALS['I18N']->get("bounces to process") . "\n"; if ($num > $max) { print $GLOBALS['I18N']->get("Processing first") . " {$max} " . $GLOBALS['I18N']->get("bounces") . "<br/>"; $report .= $num . " " . $GLOBALS['I18N']->get("processing first") . " {$max} " . $GLOBALS['I18N']->get("bounces") . "\n"; $num = $max; } if (TEST) { print $GLOBALS['I18N']->get("Running in test mode, not deleting messages from mailbox") . "<br/>"; } else { print $GLOBALS['I18N']->get("Processed messages will be deleted from mailbox") . "<br/>"; } $nberror = 0; # for ($x=1;$x<150;$x++) { for ($x = 1; $x <= $num; $x++) { set_time_limit(60); $header = imap_fetchheader($link, $x); if ($x % 25 == 0) { # outputProcessBounce( $x . " ". nl2br($header)); outputProcessBounce($x . " done", 1); } print "\n"; flush(); $processed = processImapBounce($link, $x, $header); if ($processed) { if (!TEST && $bounce_mailbox_purge) { if (VERBOSE) { outputProcessBounce($GLOBALS['I18N']->get("Deleting message") . " {$x}"); } imap_delete($link, $x); } elseif (VERBOSE) { outputProcessBounce(s("Not deleting processed message") . " {$x} {$bounce_mailbox_purge}"); } } else { if (!TEST && $bounce_mailbox_purge_unprocessed) { if (VERBOSE) { outputProcessBounce($GLOBALS['I18N']->get("Deleting message") . " {$x}"); } imap_delete($link, $x); } elseif (VERBOSE) { outputProcessBounce(s("Not deleting unprocessed message") . " {$x}"); } } flush(); } flush(); outputProcessBounce($GLOBALS['I18N']->get("Closing mailbox, and purging messages")); set_time_limit(60 * $num); imap_close($link); if ($num) { return $report; } }
function processMessages($link, $max = 3000) { global $bounce_mailbox_purge_unprocessed, $bounce_mailbox_purge; $num = imap_num_msg($link); outputProcessBounce(s('%d bounces to fetch from the mailbox', $num) . PHP_EOL); outputProcessBounce($GLOBALS['I18N']->get('Please do not interrupt this process') . PHP_EOL); $report = ' ' . s('%d bounces to process', $num) . PHP_EOL; if ($num > $max) { outputProcessBounce(s('Processing first %d bounces', $max) . PHP_EOL); $report .= s('Processing first %d bounces', $max) . PHP_EOL; $num = $max; } if (TEST) { print s('Running in test mode, not deleting messages from mailbox') . '<br/>'; } else { print s('Processed messages will be deleted from mailbox') . '<br/>'; } $nberror = 0; # for ($x=1;$x<150;$x++) { for ($x = 1; $x <= $num; ++$x) { set_time_limit(60); $header = imap_fetchheader($link, $x); if ($x % 25 == 0) { # outputProcessBounce( $x . " ". nl2br($header)); outputProcessBounce($x . ' done', 1); } print PHP_EOL; flush(); $processed = processImapBounce($link, $x, $header); if ($processed) { if (!TEST && $bounce_mailbox_purge) { if (VERBOSE) { outputProcessBounce($GLOBALS['I18N']->get('Deleting message') . " {$x}"); } imap_delete($link, $x); } elseif (VERBOSE) { outputProcessBounce(s('Not deleting processed message') . " {$x} {$bounce_mailbox_purge}"); } } else { if (!TEST && $bounce_mailbox_purge_unprocessed) { if (VERBOSE) { outputProcessBounce($GLOBALS['I18N']->get('Deleting message') . " {$x}"); } imap_delete($link, $x); } elseif (VERBOSE) { outputProcessBounce(s('Not deleting unprocessed message') . " {$x}"); } } flush(); } flush(); outputProcessBounce(s('Closing mailbox, and purging messages')); set_time_limit(60 * $num); imap_close($link); if ($num) { return $report; } }