• Halloween is coming! To celebrate the occasion, we dusted off a couple of old skins, and even created a brand new one (Pixel).
    To get into the festive spirit, install the Skins extension.
  • The new Python extension is now available. It allows customers to deploy and manage WSGI-based Python applications on their websites directly from Plesk.
  • The Plesk Mobile apps for iOS and Android and the Plesk Mobile Center extension have been deprecated, and are no longer available for new installations. In Plesk Obsidian 18.0.84, the Plesk Mobile Center extension will be removed from servers during the upgrade, and the Plesk Mobile apps will lose their server management features.
  • The Social Login extension has been deprecated and will be removed in Plesk Obsidian 18.0.84. After that, it will no longer be possible to log in to Plesk with a Google, Facebook, GitHub account, or with a passkey. Plesk usernames and passwords, as well as logging in with a WebPros Account, are not affected.

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