Delete specific email queues in Postfix

If an email message is undeliverable, it will bounce back with ‘MAILER-DAEMON’  telling you that the message could not be delivered to the destination addresses. The queue will try to keep delivering based on your mail server configuration. Unfortunately it will make your mail server takes some resources to the queues. And we dont want this thing happened.

In this example, we want to delete all ‘MAILER-DAEMON’ email queues. Using this trick you can free your mail server from ‘MAILER-DAEMON’ queues at that time. Below is the command:

for i in `postqueue -p|grep 'MAILER-DAEMON' |awk {'print $1'}|grep -v 'MAILER-DAEMON'`; do postsuper -d $i ; done

To delete all queues, simply use ‘postsuper -d ALL’ command.
Hope this trick useful for you.