add postfix cleaner for charles
authorAndrew Lorimer <andrew@charles.cortex>
Thu, 27 Dec 2018 11:37:37 +0000 (22:37 +1100)
committerAndrew Lorimer <andrew@charles.cortex>
Thu, 27 Dec 2018 11:37:37 +0000 (22:37 +1100)
postfix-delete.pl [new file with mode: 0755]
diff --git a/postfix-delete.pl b/postfix-delete.pl
new file mode 100755 (executable)
index 0000000..ab75701
--- /dev/null
@@ -0,0 +1,24 @@
+#!/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);