There are various ways to manage the qmail queue outside of the control panel.

First, connect to your server with SSH using your root username and password.

 

After logging in, you'll be presented with the bash interface, from here you can run several commands.

 

/var/qmail/bin/qmail-qstat will give you the current status of the mail queue:

root@server:~# /var/qmail/bin/qmail-qstat

messages in queue: 3

messages in queue but not yet preprocessed: 0

Once you know there are messages in the queue, you can use /var/qmail/bin/qmail-qread to read a summary of each message.

To manage the queue, you can use another command called “qmhandle”.

If you run qmhandle you’ll be able to see all the associated flags to use:

root@server:~# qmhandle

qmHandle v1.3.2

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

  -fsender : delete message from sender

  -f're'   : delete message from senders matching regular expression re

  -Stext   : delete all messages that have/contain text as Subject

  -h're'   : delete all messages with headers matching regular expression re (case insensitive)

  -b're'   : delete all messages with body matching regular expression re (case insensitive)

  -H're'   : delete all messages with headers matching regular expression re (case sensitive)

  -B're'   : delete all messages with body matching regular expression re (case sensitive)

  -t're'   : flag messages with recipients in regular expression 're' for earlier retry (note:

this lengthens the time message can stay in queue)

  -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)

An example from the above is the ability to clear all messages from a specific sender, which is very useless if a mailbox is compromised.

Qmhandle –fuser@domain.com