Clear email queues using qmHandle

Details

When the mail queue on a (dv) Dedicated-Virtual Server has messages stacked up you can use the tool qmHandle.

  1. Download qmHandle from SourceForge. You actually only need the script ‘qmHandle’ so use that if you have it handy. Upload it to the server and untar it if necessary. You may download the file directly from SourceForge using the wget command:[ad code=1 align=center]
    wget http://optusnet.dl.sourceforge.net/sourceforge/qmhandle/qmhandle-1.3.2.tar.gz
    
  2. Then decompress the file using the tar command:
    tar -xvzf qmhandle-1.3.2.tar.gz
    
  3. First it is recommended to shutdown qmail using the service command to prevent possible corruption of the mail queue:
    service qmail stop  
  4. When you are done with qmhandle be sure to start it again using the service command:
    service qmail start
    
  • qmHandle can show it’s own options when run without a flag:
    ./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
    -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
    

    -s to see some basic statistics

    qmHandle -s
    
    Messages in local queue: 0
    
    Messages in remote queue: 10

    * -l to see stats about each message in the queue. Can get very long so use -N to see just the message numbers

    qmHandle -l
    
    10601551 (0, R)
    
    Return-path:
    From: MAILER-DAEMON@domain.com
    To: someone@my-domain.com
    Subject: failure notice
    Date: 30 Mar 2006 18:12:36 -0800
    Size: 1706 bytes
    ...
    

    * -m to see a particular message. Get the message number from above

    qmHandle -m10600494
    --------------
    MESSAGE NUMBER 10600494
    --------------
    
    Received: (qmail 15035 invoked for bounce); 5 Apr 2006 08:21:30 -0700
    Date: 5 Apr 2006 08:21:30 -0700
    From: MAILER-DAEMON@domain.com
    To: someone@my-domain.net
    Subject: failure notice
    Hi. This is the qmail-send program
    ...

    * -D to delete all messages in both the incoming and outgoing queues.

    qmHandle -D
    Calling system script to terminate qmail...
    
    Deleting message: 0/10601551 [ OK ]
    Deleting message: 1/10600494
    Deleting message: 15/10601566
    Deleting message: 16/10601567
    Deleting message: 18/10601569
    Deleting message: 20/10601571
    Deleting message: 22/10601550
    Deleting message: 6/10601557
    Deleting message: 8/10601582
    Deleting message: 9/10601583
    Restarting qmail... Starting qmail: [ OK ]
    done (hopefully).
    
  • Leave a comment