1- Postfix maintains two queues, the pending mails queue, and the deferred mail queue,
the differed mail queue has the mail that has soft-fail and should be retried (Temporary failure),
Postfix retries the deferred queue on set intervals (configurable, and by default 5 minutes)

In any case, the following commands should be useful

1- Display a list of queued mail, deferred and pending

1

mailq

or

1

postqueue-p

To save the output to a text file you can run

1

mailq>myfile.txt

or

1

postqueue-p>myfile.txt

the above commands display all queued messages (Not the message itself but the sender and recipients and ID), The ID is particularly useful if you want to inspect the message itself.

2- View message (contents, header and body) in Postfix queue

Assuming the message has the ID XXXXXXX (you can see the ID form the QUEUE)

1

postcat-vq XXXXXXXXXX

Or to save it in a file

1

postcat-vq XXXXXXXXXX>themessage.txt

3- Tell Postfix to process the Queue now

1

postqueue-f

OR

1

postfix flush

4- Delete queued mail

Delete all queued mail

1

postsuper-dALL

Delete differed mail queue messages

(The ones the system intends to retry later)

1

postsuper-dALL deferred

Delete from queue selectively

To delete from the queue all emails that have a certain address in them, we can use this program (perl script)…

NOTE: This perl script seems to be free, and is all over the internet, i could not find out where it originates or who wrote it.

1- Download this file, unzip, and upload the file to your server, then from your bash command line, Change Directory to wherever you uploaded this file, for example cd /root (Just an example, You can upload it wherever you wish)

NOTE: A second script here works differently, i have not yet tested it, download it here

Now, from within that directory, execute…

1

./postfix-queue-delete.pl anyaddress@example.com

Any mail that has this email address in it’s IN or OUT list will be deleted