Skip to content

Instantly share code, notes, and snippets.

@flores
Created March 4, 2011 00:22
Show Gist options
  • Save flores/853898 to your computer and use it in GitHub Desktop.
Save flores/853898 to your computer and use it in GitHub Desktop.
Dirty: Sometimes postfix has a shitton of messages and you want to delete everything going to a (newline separated) blacklist. (Perl)
#!/usr/bin/perl -w
die "usage $0 <path to email list>\n" unless @ARGV;
my $file=$ARGV[0];
my @queue=`postqueue -p |grep -v ^- |awk 'BEGIN{RS="\\n\\n"} ; {print \$1"\t"\$NF}'`;
my @list_users=`cat $file`;
foreach my $line (@queue)
{
$line=~/^(.+?)\t(.+)$/;
$queueid = $1;
$user = $2;
if (grep(/$user/,@list_users))
{
system ("postsuper -d $queueid");
print "I am deleting $user email\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment