Queue maintenance is an important part of the administration of any SMTP mail server. There may be times where you get a lot of emails attempting to be sent, that either aren’t getting transmitted successfully, or you don’t want them to get transmitted. The “postsuper” command allows you to remove individual emails, or even all emails from the queue.
If you would like to just remove one specific email from the queue, you need to get the Queue ID. You can get this by using the “postqueue -p” command to display the emails waiting in the queue. The output should look something like this:
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- EC753D0D00* 328 Thu Apr 5 14:34:09 email@example.com firstname.lastname@example.org -- 0 Kbytes in 1 Request.
You can use the Queue ID to reference which email you want to remove from the queue using the “postsuper” command with the -d option. The command below removes the above message from the queue.
$ sudo postsuper -d EC753D0D00
Example output from the above command:
postsuper: EC753D0D00: removed postsuper: Deleted: 1 message
If you would instead like to remove all emails from the queue, you can use the following command:
(Note: ALL must be in uppercase as a safety measure).
$ sudo postsuper -d ALL
Sample output from the above command:
postsuper: Deleted: 2 messages
You can also specify which queue you would like to clear using one of the following commands:
$ sudo postsuper -d ALL hold $ sudo postsuper -d ALL incoming $ sudo postsuper -d ALL active $ sudo postsuper -d ALL deferred
For more info, check the postsuper man page by issuing the “man postsuper” command.