Created
March 4, 2011 00:22
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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