MAC OSX Mail Server – Postfix mail queue
The PostFix mail server, part of OSX Server, is a wonderfully flexible and configurable mail transfer agent. There are many ways that your Postfix message queues can become flooded with illegitimate messages.
Postfix on OSX Server can display the mail queue in terminal.
To see mail queue, enter:
# mailq
How to Delete One Email In Any Queue
postsuper -d MESSAGE_ID
How to Delete Email for a Single User In All Queues
Use the following command to delete the messages from your mail queues. Be sure to substitute ‘youruser@yourdomain\.com’ with the email account which is flooded. Be sure to escape the dot as shown in the example:
postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } / youruser@yourdomain\.com/ { print $1 }' | tr -d '*!' | postsuper -d -
If you mail server is really clogged, this can take hours to execute.
How to Delete All Email or Just In Specific Queues
To delete all deferred messages from a single queue:
postsuper -d ALL deferred
To remove all mail from the queue, enter:
# postsuper -d ALL