in linux

Inspecting Postfix’s email queue

This post explains how to view messages in the postfix queue.

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 .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



postqueue -p

To save the output to a text file you can run

mailq > myfile.txt


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)

postcat -vq XXXXXXXXXX

Or to save it in a file

postcat -vq XXXXXXXXXX > themessage.txt

3- Tell Postfix to process the Queue now

postqueue -f


postfix flush

4- Delete queued mail

Delete all queued mail

postsuper -d ALL

Delete differed mail queue messages

(The ones the system intends to retry later)

postsuper -d ALL deferred

#Or delete specific mail that receive or sent to [email protected]
mailq | awk 'BEGIN { RS = "" } / [email protected]\.com$/ { print $1 }' | tr -d '*!' | postsuper -d -