Plesk clear qmail queue

I will describe today how you can clear the queue for qmail, for a server that is running Plesk. First of all you should use one of the methods described with caution. The second method described is an automation of the first method and this is why I will include both of them. This method only removes the messages from the queue, and nothing else is lost.

First of all check the number of messages from the queue using the qmail-qstat tool:

[root@test /]# /var/qmail/bin/qmail-qstat
messages in queue: 22463
messages in queue but not yet preprocessed: 22

To remove the messages from the queue ALWAYS stop the qmail service first, to avoid having to reconfigure it again:

service qmail stop

Once the service is stopped execute the following commands one by one (based on the number of files stuck in the queue, this may take a while):

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 {} \;

Finally start the mail service and recheck the queue to ensure that all the messages have been removed:

service qmail start

To automate this process I have two scripts available (basically are performing the same operations as above). For those that receive oversized file truncating errors please use the 2nd script – it takes a little longer but gets the job done.


11 thoughts on “Plesk clear qmail queue

  1. Hi have been working on this attack for days and nights.

    you have just saved me… for now.

    Thank you so much…

    Best information I have found, including official sites.

  2. Thank you for doing this tutorial! Extremely helpful – I tried it manually first but had a problem stopping qmail so I kept getting ‘no such file or directory exists!’ though it found thousands, haha. Doing the automatic scripts fixed it for me!

    P.S. does it matter which way you run the scripts? clear or clean first? Thanks for the help!

  3. Thanks for the shared knowledge. I simplified your script slightly.
    Thanks again!

    echo “Stopping Qmail – MinisterAlan”
    /etc/init.d/qmail stop &&
    for qdir in /var/qmail/queue/{info,mess,remote,intd,local,todo}; do
    cd ${qdir}
    echo “Cleaning $(pwd)”
    rm -rf [0-9]{,[0-9]}/*
    echo “Mail queue cleaned. Re-Starting Qmail Now !”
    /etc/init.d/qmail start &&
    echo “Qmail Started – MinisterAlan”
    exit 0;

  4. Another Short Solution : Use plesk Mail Queue Manager. It will handle Everything by default.

    Use this command through SSH:
    /usr/local/psa/admin/sbin/mailqueuemng -D

    Note: It will empty the queue.

  5. Pingback: Mail Server Problems – A Thinker's Notebook

  6. Thank you for the tutorial. After loosing half a day finding out what filled up my virtual server, I got it back running.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.