mailq
or
postqueue -p
Assuming the message has the ID XXXXXXX (you can see the ID form the QUEUE)
postcat -vq XXXXXXXXXX
postqueue -f
or
postfix flush
If your server has very high load and you want to temporarily move all message from the incoming queue to the hold queue, use the command:
postsuper -h ALL
To move the messages back to the incoming queue, use the command:
postsuper -r ALL
Delete a message by message ID
postsuper -d MessageID
Delete all queued mail
postsuper -d ALL
Delete differed mail queue messages, those the system will retry later
postsuper -d ALL deferred
Remove emails by sender (hacked account spamming?)
mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($7 == “spamming@example.com” && $9 == “”) print $1 } ‘ | tr -d ‘*!’ | postsuper -d -
Remove emails by recipient (highly spammed account?)
mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($8 == "spammed@example.com" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d -
Remove emails by sender hostname
mailq | grep senderhostname | awk ‘{ print $1′} | postsuper -d -