if (isset($_SERVER['HTTP_HOST'])) { // web if (@$_GET['fix-lock'] == 1) { $fix_lock = true; } } else { // command line if (in_array('--fix-lock', $_SERVER['argv'])) { $fix_lock = true; } } // if requested, clear the lock if ($fix_lock) { Mail_Queue::removeProcessFile(); echo "The lock file was removed successfully.\n"; exit; } if (!Mail_Queue::isSafeToRun()) { $pid = Lock::getProcessID('process_mail_queue'); echo "ERROR: There is already a process (pid={$pid}) of this script running. "; echo "If this is not accurate, you may fix it by running this script with '--fix-lock' as the only parameter.\n"; exit; } ini_set("memory_limit", "256M"); // handle only pending emails $limit = 50; Mail_Queue::send('pending', $limit); // handle emails that we tried to send before, but an error happened... $limit = 50; Mail_Queue::send('error', $limit); Mail_Queue::removeProcessFile();