Created
August 20, 2014 09:16
-
-
Save fjd/162699bb4e8a0bb667ef to your computer and use it in GitHub Desktop.
postfix-delete.pl - Following script deletes all mail from the mailq which matches the regular expression specified as the first argument
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 | |
$REGEXP = shift || die "no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!"; | |
@data = qx</usr/sbin/postqueue -p>; | |
for (@data) { | |
if (/^(\w+)(\*|\!)?\s/) { | |
$queue_id = $1; | |
} | |
if($queue_id) { | |
if (/$REGEXP/i) { | |
$Q{$queue_id} = 1; | |
$queue_id = ""; | |
} | |
} | |
} | |
#open(POSTSUPER,"|cat") || die "couldn't open postsuper" ; | |
open(POSTSUPER,"|postsuper -d -") || die "couldn't open postsuper" ; | |
foreach (keys %Q) { | |
print POSTSUPER "$_\n"; | |
}; | |
close(POSTSUPER); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment