• Debian 11 is approaching its end-of-life (vendor EOL date - August 31, 2026). Plesk Obsidian 18.0.80 will be the last release to support it.
    If you are running Plesk Obsidian on Debian 11, we recommend you upgrade those servers to Debian 12 using our dist-upgrade tool.
  • We plan to deprecate and remove the support for XML RPC protocol versions earlier than 1.6.9.1 in Plesk Obsidian 18.0.82. We strongly recommend that you update all existing integrations using earlier versions of the XML RPC protocol to comply with the version 1.6.9.1 specification.

An alternative to qmHandle - a PHP Based Qmail Queue Spam Cleaner

C

criticman

Guest
For some reason, qmHandle randomly stopped working.

So, I wrote a replacement in PHP to meet my needs. All it does is delete messages containing a string of your choosing. It deletes the message, the info & remote files too.

Pretty basic, but it got the job done.

Details:
http://blog.criticman.com/2006/06/05/php-based-qmail-queue-spam-cleaner/

And here is the code:
PHP:
<?php
	/* Qmail-Queue-Cleaner.php
		Written by Matthew R Williams aka Criticman
		blog.criticman.com
		Some rights reserved.
		Please contact me if you wish to use this base code in an altered form and distribute it.
		All others welcome to use and alter for personal use (or commercial use - just do not sell it for a profit).
	*/
	
	echo "Qmail-Queue-Cleaner.php written by Criticman.\nhttp://blog.criticman.com\n\n";

	/* BEGIN USER CONFIGURATION */
	$spamLine = "/failure/"; // line of spam you want to look for in each message, in this case, 'failure'
	$messDir = "/var/qmail/queue/mess"; // location of qmail 'mess' directory
	/* END USER CONFIGURATION */
	
	echo "Searching for: " . $spamLine . "\n\n";
	
	chdir($messDir); 
	echo "Starting in... " . getcwd() . "\n";
	$handle = opendir(".");
	while (false !== ($file = readdir($handle))) {
		if ($file != "." && $file != "..") { 
			chdir($file);
			echo "\tNow in... " . getcwd() . "\n";
			$myHandle = opendir(".");
			while (false !== ($myFile = readdir($myHandle))) {
				if ($myFile != "." && $myFile != "..") {
					$fh = fopen($myFile,'rb');
					$fContents = fread($fh,1024);
					if(preg_match($spamLine,$fContents) == 1) {
						fclose($fh);
						echo "Deleting file..." . $file . "/" . $myFile . " ...done.\n";
						unlink($myFile);
						unlink("/var/qmail/queue/info/$file/$myFile");
						unlink("/var/qmail/queue/remote/$file/$myFile");
					} else {
						fclose($fh);
					}
				}
			}
			chdir("..");
		}
	} 
	closedir($handle);
	echo "Process completed (hopefully).\n";
	exit;
?>
 
Back
Top