• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

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