Queue Management with Qmail
Brand new article, just finished writing it.
This article describes the queue system of qmail, and the tools you can use to manage it. Also, it introduces a new one, called qmail-cleaner, to find messages in the queue that match a given regular expression.
BUG: At page bottom link is "a href="www.qmail.org"" in mozilla turns to http://www.pycs.net/lateral/stories/www.qmail.org => results in 404. Missing protocol http.
There may not be a qmail-cleaner script, but google for qmail-remove and you'll find a python script that does a little of what you're asking. The only thing I don't like about qmail-remove is the fact that you have you stop qmail to remove messages from the queue without running a risk of damaging your queue.
I have this error when a tried to run qmail-cleaner.py:
[root@pandora QMail]# ./qmail-cleaner.py --header=test -v
Searching messages with headers matching: test
Traceback (most recent call last):
File "./qmail-cleaner.py", line 80, in ?
check (msgdir+"/"+dir+"/"+file)
File "./qmail-cleaner.py", line 55, in check
for line in open(message):
TypeError: loop over non-sequence
Stuart: The stop qmail problem is general. If you find a script that says you don't need to do it, the script is broken :-)
Marcos: Can you tell me the python version you are using? Iterating over a file
is rather new. I can send you a patched version for older python, if you want.
MZM: thanks!
I made some changes. First of all my version of python (2.3.3) needed to import optparse instead of optik. Next for my needs I needed to match against the Return-path. so I added an opion and changed the dir to /info. Finally I used qmail-clean to call qmHandle do delete each msg (it would proably have been cleaner to do the delete in qmail-clean itself but I was in a hurry). Let me know if you're interested in the changes. What's the licsense on qmail-clean? is it GPL?
Anyone know what this error message is.....1088852852.207365 alert: unable to opendir info/1, sleeping...
The above problem has been fixed. I just have to find out a way to fix all of the bounced messages that are filling up my queue. I try to use the cleaner but get the error message.
Traceback (innermost last):
File "./qmail-cleaner.py", line 7, in ?
from optik import OptionParser
ImportError: No module named optik
I installed optik but still get an error message saying it isn't there....
Chris did you read my post? You have to change optik to optparse in any recent version of python. I'm getting ready to post my version on my website if you want to take a look.
Where can I get this optparse module?
In python 2.3.3 its in with the standard modules.
The license for this is public domain, do as you please. If you send me your version, I will publish it.
The reason to use qmHandle to delete the files is that it stops the queue processing.
Not stopping it is what causes that error about a missing file: qmail just deleted it before you.
here's a nasty little devil that will purge your bounces.. need to run qmailctl stop, and kill qmail-send if necessary.. then install this into qmail/queue, and have mod (below) compiled and in path.. if you manage that this might just not destroy your qmail..
1 #!/bin/bash
2
3 for bounce in bounce/*
4 do
5 rm $bounce
6 mid=$(basename $bounce)
7 int=$(echo "$mid 23" | mod)
8 msg=${int}/${mid}
9 for test in mess intd info local remote
10 do
11 file=${test}/${msg}
12 if [ -f ${file} ]
13 then
14 rm $file
15 fi
16 done
17 done
/* mod.c
*/
1
2 #include
3 /*
4 *
5 *
6 * jdp
7 */
8 int main( char** argv, int argc){
9 int a, b, c;
10 fscanf(stdin,"%d %d",&a;,&b;);
11 c = a % b;
12 fprintf(stdout,"%dn",c);
13 return 0;
14 }
15