Postfix service commands
The article will help you for flush, clear or delete emails from Postfix mail queue in shell. It will also help you to delete emails any specific email address.
List all emails - you can list all mail of queue, using one of the following commands:
Flush all emails - To delete or flush all emails from Postfix mail queue using the following command:
postsuper -d ALL
Flush deferred mails only - use the following command to delete deferred emails from the queue.
postsuper -d ALL deferred
Remove specific email - in case you want to remove any specific email, you can use the following command:
First search the ID of that email like below command
postqueue -p | grep "email@example.com"
0AB345F3D24* 5513 Sun Feb 26 02:26:27 firstname.lastname@example.org
Delete mail from mail queue with id 0AB345F3D24.
postsuper -d 0AB345F3D24
To count messages in queue you can use something like:
postqueue -p | grep -c "^[A-Z0-9]"
To process messages in queue you can use:
To save the message in file you can use:
postcat -vq messageid > message.txt
You can view a particular message using:
postcat -vq messageid