﻿{"id":231,"date":"2012-06-27T17:08:24","date_gmt":"2012-06-27T20:08:24","guid":{"rendered":"http:\/\/binsfeld.com.br\/wp\/?p=231"},"modified":"2012-06-27T17:56:10","modified_gmt":"2012-06-27T20:56:10","slug":"script-perl-para-apagar-fila-postfix","status":"publish","type":"post","link":"http:\/\/binsfeld.com.br\/wp\/?p=231","title":{"rendered":"Script Perl para Apagar Fila Postfix"},"content":{"rendered":"<p>Traditionally you use the &#8220;sendmail -q&#8221; command to flush mail queue under Sendmail MTA. Under Postfix MTA, just enter the following command to flush the mail queue:<br \/>\n<code># postfix flush<\/code><br \/>\nOR<br \/>\n<code># postfix -f<\/code><\/p>\n<p>To see mail queue, enter:<br \/>\n<code># mailq<\/code><\/p>\n<p>To remove all mail from the queue, enter:<br \/>\n<code># postsuper -d ALL<\/code><\/p>\n<p>To remove all mails in the deferred queue, enter:<br \/>\n<code># postsuper -d ALL deferred<\/code><\/p>\n<h2>postfix-delete.pl script<\/h2>\n<p>Following script deletes all mail from the mailq which matches the regular expression specified as the first argument (Credit: ??? &#8211; I found it on old good newsgroup)<\/p>\n<ol>\n<li>\n<div>#!\/usr\/bin\/perl<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div>$REGEXP = <a href=\"http:\/\/perldoc.perl.org\/functions\/shift.html\">shift<\/a> || <a href=\"http:\/\/perldoc.perl.org\/functions\/die.html\">die<\/a> &#8220;no email-adress given (regexp-style, e.g. bl.*\\@yahoo.com)!&#8221;;<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div>@data = qx&lt;\/usr\/sbin\/postqueue -p&gt;;<\/div>\n<\/li>\n<li>\n<div>for (@data) {<\/div>\n<\/li>\n<li>\n<div>if (\/^(\\w+)(\\*|\\!)?\\<a href=\"http:\/\/perldoc.perl.org\/functions\/s.html\">s<\/a>\/) {<\/div>\n<\/li>\n<li>\n<div>$queue_id = $1;<\/div>\n<\/li>\n<li>\n<div>}<\/div>\n<\/li>\n<li>\n<div>if($queue_id) {<\/div>\n<\/li>\n<li>\n<div>if (\/$REGEXP\/i) {<\/div>\n<\/li>\n<li>\n<div>$Q{$queue_id} = 1;<\/div>\n<\/li>\n<li>\n<div>$queue_id = &#8220;&#8221;;<\/div>\n<\/li>\n<li>\n<div>}<\/div>\n<\/li>\n<li>\n<div>}<\/div>\n<\/li>\n<li>\n<div>}<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div>#open(POSTSUPER,&#8221;|cat&#8221;) || die &#8220;couldn&#8217;t open postsuper&#8221; ;<\/div>\n<\/li>\n<li>\n<div><a href=\"http:\/\/perldoc.perl.org\/functions\/open.html\">open<\/a>(POSTSUPER,&#8221;|postsuper -d -&#8220;) || <a href=\"http:\/\/perldoc.perl.org\/functions\/die.html\">die<\/a> &#8220;couldn&#8217;t open postsuper&#8221; ;<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<li>\n<div>foreach (<a href=\"http:\/\/perldoc.perl.org\/functions\/keys.html\">keys<\/a> %Q) {<\/div>\n<\/li>\n<li>\n<div><a href=\"http:\/\/perldoc.perl.org\/functions\/print.html\">print<\/a> POSTSUPER &#8220;$_\\n&#8221;;<\/div>\n<\/li>\n<li>\n<div>};<\/div>\n<\/li>\n<li>\n<div><a href=\"http:\/\/perldoc.perl.org\/functions\/close.html\">close<\/a>(POSTSUPER);<\/div>\n<\/li>\n<li>\n<div><\/div>\n<\/li>\n<\/ol>\n<p>For example, delete all queued messages from or to the domain called fackspamdomain.com, enter:<br \/>\n<code>.\/postfix-delete.pl fackspamdomain.com<\/code><br \/>\nDelete all queued messages that contain the word &#8220;xyz&#8221; in the e-mail address:<br \/>\n<code>.\/postfix-delete.pl xyz<\/code><\/p>\n<p>Updated for accuracy.<\/p>\n<p>Cr\u00e9ditos : <a href=\"http:\/\/www.cyberciti.biz\/tips\/howto-postfix-flush-mail-queue.html\">http:\/\/www.cyberciti.biz\/tips\/howto-postfix-flush-mail-queue.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Traditionally you use the &#8220;sendmail -q&#8221; command to flush mail queue under Sendmail MTA. Under Postfix MTA, just enter the following command to flush the mail queue: # postfix flush<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-231","post","type-post","status-publish","format-standard","hentry","category-firewall"],"_links":{"self":[{"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=\/wp\/v2\/posts\/231"}],"collection":[{"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=231"}],"version-history":[{"count":2,"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=\/wp\/v2\/posts\/231\/revisions"}],"predecessor-version":[{"id":233,"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=\/wp\/v2\/posts\/231\/revisions\/233"}],"wp:attachment":[{"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=231"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/binsfeld.com.br\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}