{"id":116,"date":"2015-09-14T11:44:48","date_gmt":"2015-09-14T09:44:48","guid":{"rendered":"http:\/\/www.shvek.com\/?p=116"},"modified":"2015-09-14T11:44:48","modified_gmt":"2015-09-14T09:44:48","slug":"script-to-remove-mails-from-postfix-queue-based-on-keyword","status":"publish","type":"post","link":"https:\/\/shvek.com\/?p=116","title":{"rendered":"Script to Remove Mails from Postfix Queue based on keyword."},"content":{"rendered":"<p>This perl script will bulk remove emails from the Postfix mail queue based on a keyword, email domain, or email address.\u00a0 The script came from <a href=\"http:\/\/jwcub.wordpress.com\/2006\/01\/20\/bulk-delete-from-postfix-queue\/\">this blog post<\/a>:<\/p>\n<pre>#!\/usr\/bin\/perl\r\n\r\n$REGEXP = shift || die \"no email-adress given\r\n  (regexp-style, e.g. bl.*\\@yahoo.com)!\";\r\n\r\n@data = qx&lt;\/usr\/sbin\/postqueue -p&gt;;\r\nfor (@data) {\r\n  if (\/^(\\w+)(\\*|\\!)?\\s\/) {\r\n    $queue_id = $1;\r\n  }\r\n  if($queue_id) {\r\n    if (\/$REGEXP\/i) {\r\n      $Q{$queue_id} = 1;\r\n      $queue_id = \"\";\r\n    }\r\n  }\r\n}\r\n\r\nopen(POSTSUPER,\"|postsuper -d -\") || die \"couldn't open postsuper\" ;\r\n\r\nforeach (keys %Q) {\r\n  print POSTSUPER \"$_\\n\";\r\n};\r\n\r\nclose(POSTSUPER);\r\n<\/pre>\n<p>Before running the script:<\/p>\n<pre>chmod 755 &lt;scriptName.pl&gt;<\/pre>\n<p>Example commands:<\/p>\n<pre>.\/&lt;scriptName.pl&gt; iamspammer.com\r\n.\/&lt;scriptName.pl&gt; bogususer@mydomain.com\r\n.\/&lt;scriptName.pl&gt; bush*\\@whateverdomain.com\r\n.\/&lt;scriptName.pl&gt; biz<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This perl script will bulk remove emails from the Postfix mail queue based on a keyword, email domain, or email address.\u00a0 The script came from this<span class=\"excerpt-hellip\"> [\u2026]<\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-116","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/shvek.com\/index.php?rest_route=\/wp\/v2\/posts\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shvek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shvek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shvek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shvek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=116"}],"version-history":[{"count":1,"href":"https:\/\/shvek.com\/index.php?rest_route=\/wp\/v2\/posts\/116\/revisions"}],"predecessor-version":[{"id":117,"href":"https:\/\/shvek.com\/index.php?rest_route=\/wp\/v2\/posts\/116\/revisions\/117"}],"wp:attachment":[{"href":"https:\/\/shvek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shvek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shvek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}