Deleting messages to a specific recipient from the postfix queue
This is occasionally necessary. The code below is from the man page for postsuper.
1 2 3 4 5 6 7 8 |
mailq | grep -v '^ *(' |
awk 'BEGIN { RS = "" } {
if ($8 == "you@domain.com")
print $1
}' |
tr -d '*!' | sudo postsuper -d -
|
The first line shows the entire mail queue. The second part gets the various parts of each message. So, $7 is the sender here, $8 is the first recipient, and $9 the second recipient etc.
So, if you wanted to change it to delete all messages from someone in the postfix queue, you could say $7 == “some_sender@domain.com”
The final part sends each message id to postsuper, which reads from stdin if the final option is -.
May 10, 2010

