March 2019

How to Purge the postfix Mail Queue

To clear the mail queue in Postfix, we will use the command called postsuper . “postsuper” is short for Postfix superintendent. The postsuper command is used for postfix mail queue related maintenance work and can only be run as a superuser (root).
To check the mail queue in system, we use mailq command . Using the mailq command will show a list of e-mail messages that have not been delivered. Most of the messages will have a status of “deferred” and sit in the deferred queue .

First run the command mailq command to check how many messages are in queue overall.

There are three likely scenarios that you will need to blow away the queue:

Scenario 1 : Remove particular mail queue id (on running mailq command,you will get mail queue id)

postsuper -d mail_queue_id

Scenario 2: Remove ALL messages from all queue

postsuper -d ALL

Scenario 3: Remove only ALL deferred messages which are in the deferredqueue

postsuper -d ALL deferred