| Subcribe via RSS

Delete mail queue from or to a specific email address

March 25th, 2010 | 270 Comments | Posted in Mail server

Some times, you may need to delete mail queue from or to a specific email address in your Postfix mail server.   For example, if  you get spam attack that fills your server with a lot of emails from the same sender email address or to the same recipient email address, you need to clean those emails from your mail queue.

Manually deleting those email is very time consuming.  Here are the step to clean those email with one single command:

for i in `/usr/sbin/postqueue -p|grep '[email protected]' |awk {'print $1'}|grep -v '[email protected]'`; do /usr/sbin/postsuper -d $i ; done

This command will delete mail queue from or to [email protected].  To check current mail queue, run this command:

/usr/sbin/postqueue -p

Your mail queue will be much shorter.

Tags: ,