Skip to content

Instantly share code, notes, and snippets.

@benwalton
Created February 9, 2012 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save benwalton/1777718 to your computer and use it in GitHub Desktop.
Save benwalton/1777718 to your computer and use it in GitHub Desktop.
Clean up emails in the queue. usage ./postfix-delete.pl email@example.com
#!/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,"|/usr/sbin/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