Throughout my work as a sysadmin, managing qmail's queue seemed to be something that I often found myself doing, like, for instance when a server becomes deluged in spam from a Joe-job. At work we generally use qmHandle, an excellent piece of software. It, however, doesn't have quite all of the functions that we required, so I modifed qmHandle to give the -tX "string" and -M options that are seen below. qmHandle is licensed under the GPL. (See the documentation included in the tarball for more details).

As requested, I've updated the patch and applied it to version 1.2.0, appended a release tag of 'bovine', and updated the included documentation to reflect that it is a patched version. While version 1.2.0-bovine is mostly untested, you shouldn't have any problems with it, as no real code changes were made. In any case, version 1.1.1 is still available for download.

Here's the usage (obtained by running w/o any args):

qmHandle v1.2.0-bovine
Copyright 1998-2003 Michele Beltrame
Patched 2004-2006 Robert McLeay

Available parameters:
  -V     : print program version
  -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)
  -tX 'string': delete all messages with matching headers, where 'string' is the
                string to match and X specifies:
                  'f'  : Who the message is from,
                  't'  : Who the message is to; or,
                  's'  : What the message's subject is
  -M          : delete all msgs in the queue from
                [email protected]
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

Download the patched qmHandle: