LATHAMA
Andrew Latham aka lathama, gringo malvado

Deleting massive amounts of spam from Postfix queue

Cleaning up a postfix mail queue is both dangerous and important when situations require it.

There will come a time when every admin needs to preform magic. This is some magic to remove emails from a Postfix queue when you have hundreds of thousands of emails and the mailq command can't finish.

mailq | awk 'BEGIN { RS = "" } /domain.com/' | sed 's/!//' | postsuper -d -

In laymans terms, this script runs the mailq program and starts working on the output. This is both dangerous and fast. AWK jumps in and gets the mail ID and then SED will trim out the ! character if it is present, lastly the postsuper -d will delete what ever it gets. Change domain.com for whatever source of spam you are getting. If it is a country code you are having problems with you can do ".cc" for the TLD. Please use with caution.

Written by Andrew Latham on Tuesday March 17, 2015
Permalink - Tag: security

« Web Comics - Layout Changes with Mediawiki »