postqueue guide

Posted on Tuesday June 6th, 2017

This is a quick and dirty guide to the postfix queue - which handles mail which is queued for delivery but not sent (as yet).

To see what's in the queue, issue this command:

postqueue -p

which produces output similar to this:

5642B4D8647* 1683500 Tue Jun  3 08:37:27

9359B4D82B1* 1635730 Tue Jun  3 08:36:53

To force a flush of the queue (basically, try to send eveything in the queue) issue the command:

postqueue -f

You can also use the message ID (the first number in the queue list entries) to specify that mail to be deleted with the postsuper command. For example:

postsuper -d 5642B4D8647

If you have a list of message ids in a file (one per line) to delete, then a simple script can be written:

while IFS= read -r var
  postsuper -d $var
done < "$input"

Finally to delete all deferred messages:

postsuper -d deferred

Credit where credit is due: