Archive for Qmail Server

Qmail-Remove - better than qmHandle

Today in a Plesk server, email was not working. Plesk uses qmail mail server. It is found 567154 emails in mail que.

[root@mail bin]# /var/qmail/bin/qmail-qstat
messages in queue: 567154
messages in queue but not yet preprocessed: 3
[root@mail bin]#

So i installed qmHandle, but for some reason, it won’t work. It give some error when trying to delete the emails. May be due to large number of emails in Que.

So i installed Qmail-Remove available at

http://www.linuxmagic.com/

Installation was easy

[root@mail root]# tar -zxvf qmail-remove-0.94.tar.gz
qmail-remove-0.94/
qmail-remove-0.94/Changelog
qmail-remove-0.94/INSTALL
qmail-remove-0.94/LICENSE
qmail-remove-0.94/Makefile
qmail-remove-0.94/README
qmail-remove-0.94/TODO
qmail-remove-0.94/populate.pl
qmail-remove-0.94/qmail-remove.c
[root@mail root]# cd qmail-remove-0.94
[root@mail qmail-remove-0.94]# make
gcc -O2 -Wall -o qmail-remove qmail-remove.c
[root@mail qmail-remove-0.94]# make install
strip qmail-remove
cp qmail-remove /usr/local/sbin
[root@mail qmail-remove-0.94]# mkdir /var/qmail/queue/yanked
[root@mail qmail-remove-0.94]#

After install, you can run Qmail Remove with command

[root@mail bin]# qmail-remove
qmail-remove [options]
-e use extended POSIX regular expressions
-h, -? this help message
-i search case insensitively [default: case sensitive]
-n limit our search to the first bytes of each file
-p specify the pattern to search for
-q specify the base qmail queue dir [default: /var/qmail/queue]
-r actually remove files, without this we’ll only print them
-s specify your conf-split value if non-standard [default: 23]
-v increase verbosity (can be used more than once)
-y directory to put files yanked from the queue [default: /yanked]
-X modify timestamp on matching files, to make qmail expire mail
is the number of seconds we want to move the file into the past.
specifying a value of 0 causes this to default to (604800)
-x modify timestamp on matching files, to make qmail expire mail
is a date/time string in the format of output of the “date” program.
see manpage for strptime(2) for details of this format
[root@mail bin]#

To delete mails from Que,

qmail-remove -r -p STRING-HERE

STRING-HERE should be replaced with string that is in SPAM emails.

# qmail-remove -r -p dedicated.abac.net
324001: yes
moved mess/0/324001 to yanked/324001.mess
moved remote/0/324001 to yanked/324001.remote
moved info/0/324001 to yanked/324001.info
324024: yes
moved mess/0/324024 to yanked/324024.mess
moved remote/0/324024 to yanked/324024.remote
moved info/0/324024 to yanked/324024.info

This will remove all emails in que with “dedicated.abac.net” in it and place it in a folder.

/var/qmail/queue/yanked

Comments off

Installing qmail qmHandle

This is a simple program that allows you to view and manage (withing some limits) the qmail queue, both remote and local.

With this program you can:

* Read the qmail queue, like you do with the qmail-qread program. However, the output of this program is improved over qmail-qread, with the output of the message subjects and color capabilities.

* Print queue statistics, like qmail-qstat, with color capabilities

* View a message in the queue.
* Remove one or more messages from the queue.

* Force qmail to send queued messages immediately.

You can download qmHandle from

http://qmhandle.sourceforge.net

After downloading, unzip the file

freebsd# tar -zxvf qmhandle-1.2.0.tar.gz
GPL
HISTORY
README
qmHandle
freebsd#

Now you need to chmod the file qmHandle

freebsd# chmod 755 qmHandle

Next, edit qmHandle and set few configuration options, qmHandle is ready to go.

First set path to qmail que

my ($queue) = ‘/var/qmail/queue/’;

Then set start/stop command for qmail

On FreeBSD, it will be

my ($stopqmail) = ‘/usr/bin/qmailctl stop’;
my ($startqmail) = ‘/usr/bin/qmailctl start’;

On Linux, it will be

my ($stopqmail) = ‘/etc/init.d/qmail stop’;
my ($startqmail) = ‘/etc/init.d/qmail start’;

On FreeBSD servers, you have to change

my ($pidcmd) = ‘pidof qmail-send’;

to

my ($pidcmd) = ‘ps -U qmails | grep qmail-send | cut -s -d ” ” -f 3′;

as there is no pidof command on FreeBSD.

freebsd# ./qmHandle
qmHandle v1.2.0
Copyright 1998-2003 Michele Beltrame

Available parameters:
-a : try to send queued messages now (qmail must be running)
-l : list message queues
-L : list local message queue
-R : list remote message queue
-s : show some statistics
-mN : display message number N
-dN : delete message number N
-Stext : delete all messages that have/contain text as Subject
-D : delete all messages in the queue (local and remote)
-V : print program version

Additional (optional) parameters:
-c : display colored output
-N : list message numbers only
(to be used either with -l, -L or -R)

You can view/delete multiple message i.e. -d123 -v456 -d567

freebsd#

Comments (1)