How to delete or remove your qmail server queue?

Different Technics how to delete or remove your qmail server queue?

Qmail-Remove

This is definitely my first choice.Qmail-Remove will remove messages containing a particular string from your Qmail queue.

Mails are *not* deleted from the queue! They are only stored, temporarily, in $qmail-queue/yanked/, where you can view them individually and restore them back to the queue manually. There is currently no support for restoring them automatically.

By default, Qmail-Remove assumes that your Qmail queue is stored in /var/qmail/queue, but this can be changed with a command line option. Similarly, Qmail-Remove assumes that your queue “split” is 23 by default, among other things.

If you want to check your qmail queue using the following command

# /var/qmail/bin/qmail-qstat

Output looks like

messages in queue: 567154
messages in queue but not yet preprocessed: 3

Install Qmail-Remove

First you need to download latest version from here current version is Qmail-Remove 0.95

Download using the following command

#wget http://www.linuxmagic.com/opensource/qmail/qmail-remove/qmail-remove-0.95.tar.gz

Now you have qmail-remove-0.95.tar.gz file and now you need to extract using the following command

#tar -zxvf qmail-remove-0.95.tar.gz

Now you should have qmail-remove-0.95 folder go in to the directory and run the following commands

#make

#make install

This will complete the installation.

Now you need to create a directory named “yanked” in the qmail queue directory you intend to use before using this program.

#mkdir /var/qmail/queue/yanked

Using qmail-remove

Syntax

qmail-remove [options]

Available 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.

Examples for qmail-remove

Before doing any thing related to qmail queue you need to stop the qmail service using the following command

#/etc/init.d/qmail stop

To delete mails from Que,

#qmail-remove -r -p

# qmail-remove -r -p gtre.ac.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 “gtre.ac.net” in it and place it in /var/qmail/queue/yanked folder.

qmhandle

qmHandle is a simple program which allows you to view and manage the qmail message queue.

qmHandle Advantages

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;

You can print queue statistics, like qmail-qstat, with color capabilities;

You can view a message in the queue;

You can remove one or more messages from the queue;

Written in Perl, and therefore easily customizable and truly multiplatform.

Install qmhandle

First you need to download latest version from here and the current version is qmhandle-1.2.0

Download using the following command

#wget http://mesh.dl.sourceforge.net/sourceforge/qmhandle/qmhandle-1.2.0.tar.gz

Now you have qmhandle-1.2.0.tar.gz file you need to extract using the following command

#tar xzvf qmhandle-1.2.0.tar.gz

You should be having qmhandle-1.2.0 folder go in to the folder and you need to edit the qmHandle file to configure the following settings

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

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

my ($startqmail) = “/etc/init.d/qmail start”;

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

Using qmHandle

Available options for qmHandle

Available parameters are:-a : try to send all 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

-vN : 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 & remote)

-V : print program version

Additional (optional) parameters are:

-c : display colored output

-N : list message numbers only (to be used either with -l, -L or -R)

Examples

list message queues

#qmHandle -l

delete all messages that have/contain text as Subject

#qmHandle -l -S yahoo.com.tw

Other Solutions

1)You can edit the /var/qmail/control/queuelifetime file this is the file to control how long a message stays in a queue.Just put a number (to represent seconds)in this file.By default 86400 sec Will keep the mail for 1 day and expire after that.Here you can change this value to 1 and restart your qmail server it should clear your qmail queue.

2)Deleting mails from qmail queue

Following commands can delete all mails from your qmail mail server queue.

qmailctl stop
find /var/qmail/queue/mess -type f -exec rm {} \;
find /var/qmail/queue/info -type f -exec rm {} \;
find /var/qmail/queue/local -type f -exec rm {} \;
find /var/qmail/queue/intd -type f -exec rm {} \;
find /var/qmail/queue/todo -type f -exec rm {} \;
find /var/qmail/queue/remote -type f -exec rm {} \;
qmailctl start

 

Advertisements
This entry was posted in Qmail. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s