Postfix empty / delete all mail queue command line

Empty Postfix Mail Queue

This command will delete one specific email from the mailq (taken from the postsuper man page)


I use a few scripts that check the status of our servers and email/page me if they don’t respond. This led to a problem when I was offline for one reason or another. I would get a ton of messages sent to the postfix queue which would all be sent out when I reconnected to the internet. Deleting the postfix mail Queue is suprisingly easy:This command will delete all messages in the Postfix queue. If you need more selective deleting, this can be done as well, use ‘man postsuper’ to find out all of the available options.


The other thing that helped with this was checking for a local network connection before doing the server checks. This is done with the following.

To flush or purge the postfix mail queue, just enter this command

[/crayon]
But if you need to delete an individual email from the queue, you’ll first need to see the queue. Traditionally you use

this time we’ll use:

[/crayon]
And the output should show all messages in queue:

[/crayon]
The first number is the message ID, if you only want to delete one of them, enter:

[/crayon]
That will only delete one email for the queue, that specific email you want to delete from it.

If you want to delete all deferred mails, you can use:

[/crayon]



Comments

comments

Leave a Reply