<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Postfix Flush the Mail Queue</title> <atom:link href="http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html/feed" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html</link> <description>This is a Linux sys admin journal by Vivek about sys admin work, Linux tips &#38; tricks, hacks, news and more.</description> <lastBuildDate>Fri, 10 Feb 2012 20:37:43 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Jose</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-178660</link> <dc:creator>Jose</dc:creator> <pubDate>Mon, 16 Jan 2012 15:47:19 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-178660</guid> <description>All scripts in this thread are gonna FAIL because the lines provided by &quot;postqueue -p&quot; can generate the following two lines, being the second an explanation of the first:
0EE281EAE6C    78231 Mon Jan 16 00:35:08  aaa@hotmail.com
(line including for some reason a mail from yahoo, like recipient@yahoo.com )
and if you run it against the domain .*@yahoo.com, the script is gonna delete the entry from domain aaa@hotmail.com, when it shouldn&#039;t.
To solve it, you should have this:
&lt;pre&gt;
if (/^(\w+)(\*&#124;\!)?\s/) {
$queue_id = $1;
} else {
$queue_id = &quot;&quot;;
}
&lt;/pre&gt;
&lt;pre&gt;
Instead of just this:
if (/^(\w+)(\*&#124;\!)?\s/) {
$queue_id = $1;
} else {
$queue_id = &quot;&quot;;
}
&lt;/pre&gt;
(The mighty Ruby script will fail for the same reason, and is gonna be fixed as well with the &quot;else&quot; help)</description> <content:encoded><![CDATA[<p>All scripts in this thread are gonna FAIL because the lines provided by &#8220;postqueue -p&#8221; can generate the following two lines, being the second an explanation of the first:<br
/> 0EE281EAE6C    78231 Mon Jan 16 00:35:08 <a
href="mailto:aaa@hotmail.com">aaa@hotmail.com</a><br
/> (line including for some reason a mail from yahoo, like <a
href="mailto:recipient@yahoo.com">recipient@yahoo.com</a> )</p><p>and if you run it against the domain .*@yahoo.com, the script is gonna delete the entry from domain <a
href="mailto:aaa@hotmail.com">aaa@hotmail.com</a>, when it shouldn&#8217;t.</p><p>To solve it, you should have this:</p><pre>
  if (/^(\w+)(\*|\!)?\s/) {
     $queue_id = $1;
  } else {
     $queue_id = "";
  }
</pre><pre>
Instead of just this:
  if (/^(\w+)(\*|\!)?\s/) {
     $queue_id = $1;
  } else {
     $queue_id = "";
  }
</pre><p>(The mighty Ruby script will fail for the same reason, and is gonna be fixed as well with the &#8220;else&#8221; help)</p> ]]></content:encoded> </item> <item><title>By: Ali Ramzan</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-177283</link> <dc:creator>Ali Ramzan</dc:creator> <pubDate>Wed, 21 Dec 2011 05:59:46 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-177283</guid> <description>My requirement is postfix send 10emails in 1min.Whole postfix server send just 10 emails in 1min.
How can i do this ? any one help me?</description> <content:encoded><![CDATA[<p>My requirement is postfix send 10emails in 1min.Whole postfix server send just 10 emails in 1min.</p><p>How can i do this ? any one help me?</p> ]]></content:encoded> </item> <item><title>By: Luigi Molinaro</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-175506</link> <dc:creator>Luigi Molinaro</dc:creator> <pubDate>Tue, 08 Nov 2011 11:30:49 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-175506</guid> <description>Thanks fot your awesome works !</description> <content:encoded><![CDATA[<p>Thanks fot your awesome works !</p> ]]></content:encoded> </item> <item><title>By: Roman</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-171965</link> <dc:creator>Roman</dc:creator> <pubDate>Thu, 16 Jun 2011 08:45:16 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-171965</guid> <description>Cool, thanks for the script, worked just fine at my end, just change the paths in the script and that&#039;s it.
Thanks again!</description> <content:encoded><![CDATA[<p>Cool, thanks for the script, worked just fine at my end, just change the paths in the script and that&#8217;s it.</p><p>Thanks again!</p> ]]></content:encoded> </item> <item><title>By: Kwex</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-171884</link> <dc:creator>Kwex</dc:creator> <pubDate>Sun, 12 Jun 2011 20:20:03 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-171884</guid> <description>I use Fedora and had problems running this script. I replaced with this line
open(POSTSUPER,&quot;&#124;/usr/sbin/postsuper -d -&quot;) &#124;&#124; die &quot;couldn&#039;t open postsuper&quot; ;
and it worked fine.
Thanks!</description> <content:encoded><![CDATA[<p>I use Fedora and had problems running this script. I replaced with this line</p><p>open(POSTSUPER,&#8221;|/usr/sbin/postsuper -d -&#8221;) || die &#8220;couldn&#8217;t open postsuper&#8221; ;</p><p>and it worked fine.</p><p>Thanks!</p> ]]></content:encoded> </item> <item><title>By: Patrick Matsumura</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-171589</link> <dc:creator>Patrick Matsumura</dc:creator> <pubDate>Fri, 27 May 2011 10:21:37 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-171589</guid> <description>Just use &lt;strong&gt;mailq</description> <content:encoded><![CDATA[<p>Just use <strong>mailq</strong></p> ]]></content:encoded> </item> <item><title>By: MutluMaymun</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-170283</link> <dc:creator>MutluMaymun</dc:creator> <pubDate>Wed, 23 Mar 2011 02:23:43 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-170283</guid> <description>Wow - do you seriously have to write a comment to insult someone after 3 years? While what you said has been said a few lines below, years ago?</description> <content:encoded><![CDATA[<p>Wow &#8211; do you seriously have to write a comment to insult someone after 3 years? While what you said has been said a few lines below, years ago?</p> ]]></content:encoded> </item> <item><title>By: Harvey</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-170071</link> <dc:creator>Harvey</dc:creator> <pubDate>Sat, 19 Mar 2011 05:00:05 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-170071</guid> <description>Wow - you seriously just run any commands you find in a forum on your job&#039;s production servers? You deserved that pink slip.</description> <content:encoded><![CDATA[<p>Wow &#8211; you seriously just run any commands you find in a forum on your job&#8217;s production servers? You deserved that pink slip.</p> ]]></content:encoded> </item> <item><title>By: nxvir</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-168659</link> <dc:creator>nxvir</dc:creator> <pubDate>Wed, 09 Feb 2011 11:12:12 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-168659</guid> <description>How to read mail in queue? I could not find that command. Like we do in
exim -Mvh id
exim -Mvb id
What is the command for postfix?</description> <content:encoded><![CDATA[<p>How to read mail in queue? I could not find that command. Like we do in<br
/> exim -Mvh id<br
/> exim -Mvb id</p><p>What is the command for postfix?</p> ]]></content:encoded> </item> <item><title>By: Alessandro</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-154789</link> <dc:creator>Alessandro</dc:creator> <pubDate>Mon, 05 Apr 2010 12:02:48 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-154789</guid> <description>It&#039;s works for me. Very nice Script VIVEK.</description> <content:encoded><![CDATA[<p>It&#8217;s works for me. Very nice Script VIVEK.</p> ]]></content:encoded> </item> <item><title>By: lemsx1</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-154101</link> <dc:creator>lemsx1</dc:creator> <pubDate>Thu, 04 Mar 2010 18:09:23 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-154101</guid> <description>Some say Perl is becoming a lost art ;-) Here is my Ruby re-write (a bit more efficient. it uses practically no memory)
Save as postfix-purge-queue and run every 1 min from a cron job.
Change the path to match your own binaries. This assumes Solaris (+ blastwave) paths:
&lt;pre&gt;#!/opt/csw/bin/ruby
# vi: ft=ruby :
#
#  !! lemsx1 $$@$$ gmail !! com
# 2010-03-04 12:20 EST
#
# Cleans postfix mail queue on Solaris
# set debug to true when testing regex:
debug = false
regex = &quot;example\.(com&#124;net&#124;org)&#124;Host\s+or\s+domain\s+name\s+not\s+found&quot;
IO.popen(&quot;/opt/csw/sbin/postqueue -p&quot;) do &#124;readme&#124;
q_id = nil
readme.each do &#124;line&#124;
if line =~ /^(\w+)(\*&#124;\!)?\s/
q_id = $1
end
if q_id
if line =~ /#{regex}/
if debug
puts &quot;matching #{q_id}&quot;
else
`/opt/csw/sbin/postsuper -d #{q_id} &gt; /dev/null 2&gt;&amp;1`
end
q_id=nil
end
end
end
end&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>Some say Perl is becoming a lost art ;-) Here is my Ruby re-write (a bit more efficient. it uses practically no memory)</p><p>Save as postfix-purge-queue and run every 1 min from a cron job.</p><p>Change the path to match your own binaries. This assumes Solaris (+ blastwave) paths:</p><pre>#!/opt/csw/bin/ruby
# vi: ft=ruby :
#
#  !! lemsx1 $$@$$ gmail !! com
# 2010-03-04 12:20 EST
#
# Cleans postfix mail queue on Solaris
# set debug to true when testing regex:
debug = false
regex = "example\.(com|net|org)|Host\s+or\s+domain\s+name\s+not\s+found"
IO.popen("/opt/csw/sbin/postqueue -p") do |readme|
    q_id = nil
    readme.each do |line|
        if line =~ /^(\w+)(\*|\!)?\s/
            q_id = $1
        end
        if q_id
            if line =~ /#{regex}/
                if debug
                    puts "matching #{q_id}"
                else
                    `/opt/csw/sbin/postsuper -d #{q_id} &gt; /dev/null 2&gt;&amp;1`
                end
            q_id=nil
            end
        end
    end
end</pre>]]></content:encoded> </item> <item><title>By: salman</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-149130</link> <dc:creator>salman</dc:creator> <pubDate>Thu, 25 Jun 2009 09:43:12 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-149130</guid> <description>thanx alot alot ................... for the script it works very very very well ...... very very very well done .... !!!!!!!!!!!!!!</description> <content:encoded><![CDATA[<p>thanx alot alot &#8230;&#8230;&#8230;&#8230;&#8230;&#8230;. for the script it works very very very well &#8230;&#8230; very very very well done &#8230;. !!!!!!!!!!!!!!</p> ]]></content:encoded> </item> <item><title>By: somono</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-147137</link> <dc:creator>somono</dc:creator> <pubDate>Wed, 11 Feb 2009 08:08:02 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-147137</guid> <description>If a queue_id of - is specified, the program  reads queue  IDs  from  standard  input.  For example, to delete  all  mail  with   exactly   one   sender info@msn.com :
&lt;pre&gt;mailq &#124; tail +2 &#124; grep -v &#039;^ *(&#039; &#124; awk  &#039;BEGIN { RS = &quot;&quot; }
# $7=sender, $8=recipient1, $9=recipient2
{ if ($7 == &quot;info@msn.com&quot;)
print $1 }
&#039; &#124; tr -d &#039;*!&#039; &#124; postsuper -d -&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>If a queue_id of &#8211; is specified, the program  reads queue  IDs  from  standard  input.  For example, to delete  all  mail  with   exactly   one   sender <a
href="mailto:info@msn.com">info@msn.com</a> :</p><pre>mailq | tail +2 | grep -v '^ *(' | awk  'BEGIN { RS = "" }
              # $7=sender, $8=recipient1, $9=recipient2
               { if ($7 == "info@msn.com")
               print $1 }
              ' | tr -d '*!' | postsuper -d -</pre>]]></content:encoded> </item> <item><title>By: Sean</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-145516</link> <dc:creator>Sean</dc:creator> <pubDate>Fri, 07 Nov 2008 15:27:23 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-145516</guid> <description>Manuel, learn to indent.</description> <content:encoded><![CDATA[<p>Manuel, learn to indent.</p> ]]></content:encoded> </item> <item><title>By: pd</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-144464</link> <dc:creator>pd</dc:creator> <pubDate>Fri, 25 Jul 2008 02:08:33 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-144464</guid> <description>is there someone help me out? i need scripts to check how many emails bounced or deferred or sent?
if bounced or deferred then why? like full details message?</description> <content:encoded><![CDATA[<p>is there someone help me out? i need scripts to check how many emails bounced or deferred or sent?<br
/> if bounced or deferred then why? like full details message?</p> ]]></content:encoded> </item> <item><title>By: Manuel</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-143650</link> <dc:creator>Manuel</dc:creator> <pubDate>Fri, 02 May 2008 01:20:50 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-143650</guid> <description>Wow This is a seriously crappy coding job. Who writes this stuff? I cleaned this up to not only make sure this was scoped correctly, but also try to have a novice perl user understand it.
#!/usr/bin/perl
my $REGEXP = shift(@ARGV) &#124;&#124; die &quot;no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!&quot;;
my %Q;
my $queue_id;
my @data = `/usr/sbin/postqueue -p`;
foreach my $line (@data) {
if ($line =~ /^(\w+)(\*&#124;\!)?\s/) {
$queue_id = $1;
}
if($queue_id) {
if ($line =~ /$REGEXP/i) {
$Q{$queue_id} = 1;
$queue_id = &quot;&quot;;
}
}
}
open(POSTSUPER,&quot;&#124;postsuper -d -&quot;) &#124;&#124; die &quot;couldn&#039;t open postsuper&quot; ;
foreach my $key (keys %Q) {
print POSTSUPER &quot;$key\n&quot;;
}
close(POSTSUPER);
Hopefully this helps.. I cannot confirm that this works, just cleaned it up so that it makes sense.</description> <content:encoded><![CDATA[<p>Wow This is a seriously crappy coding job. Who writes this stuff? I cleaned this up to not only make sure this was scoped correctly, but also try to have a novice perl user understand it.</p><p>#!/usr/bin/perl</p><p>my $REGEXP = shift(@ARGV) || die &#8220;no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!&#8221;;</p><p>my %Q;<br
/> my $queue_id;<br
/> my @data = `/usr/sbin/postqueue -p`;<br
/> foreach my $line (@data) {<br
/> if ($line =~ /^(\w+)(\*|\!)?\s/) {<br
/> $queue_id = $1;<br
/> }<br
/> if($queue_id) {<br
/> if ($line =~ /$REGEXP/i) {<br
/> $Q{$queue_id} = 1;<br
/> $queue_id = &#8220;&#8221;;<br
/> }<br
/> }<br
/> }</p><p>open(POSTSUPER,&#8221;|postsuper -d -&#8221;) || die &#8220;couldn&#8217;t open postsuper&#8221; ;</p><p>foreach my $key (keys %Q) {<br
/> print POSTSUPER &#8220;$key\n&#8221;;<br
/> }<br
/> close(POSTSUPER);</p><p>Hopefully this helps.. I cannot confirm that this works, just cleaned it up so that it makes sense.</p> ]]></content:encoded> </item> <item><title>By: Jim</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-143572</link> <dc:creator>Jim</dc:creator> <pubDate>Thu, 24 Apr 2008 18:30:26 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-143572</guid> <description>I&#039;ve found this code on two different blogs and have received compilation errors both times similar to:
Unmatched right curly bracket at ./delete-queue line 9, at end of line
(Might be a runaway multi-line ;; string starting on line 5)
syntax error at ./postfix-delete.pl line 9, near &quot;}&quot;
Execution of ./postfix-delete.pl aborted due to compilation errors.
I&#039;m more of a PHP person so Perl&#039;s not my thing. I know syntax is really important and I&#039;ve double and triple checked to make sure things are correct, including composing in vi, pico and bbedit editors.
??</description> <content:encoded><![CDATA[<p>I&#8217;ve found this code on two different blogs and have received compilation errors both times similar to:</p><p>Unmatched right curly bracket at ./delete-queue line 9, at end of line<br
/> (Might be a runaway multi-line ;; string starting on line 5)<br
/> syntax error at ./postfix-delete.pl line 9, near &#8220;}&#8221;<br
/> Execution of ./postfix-delete.pl aborted due to compilation errors.</p><p>I&#8217;m more of a PHP person so Perl&#8217;s not my thing. I know syntax is really important and I&#8217;ve double and triple checked to make sure things are correct, including composing in vi, pico and bbedit editors.<br
/> ??</p> ]]></content:encoded> </item> <item><title>By: Henk</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-142131</link> <dc:creator>Henk</dc:creator> <pubDate>Tue, 11 Dec 2007 15:46:54 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-142131</guid> <description>I think matt deserves a pink slip from his employer, because he uses commands found on random sites without even checking what the effects are!</description> <content:encoded><![CDATA[<p>I think matt deserves a pink slip from his employer, because he uses commands found on random sites without even checking what the effects are!</p> ]]></content:encoded> </item> <item><title>By: vivek</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-142126</link> <dc:creator>vivek</dc:creator> <pubDate>Tue, 11 Dec 2007 08:45:56 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-142126</guid> <description>Matt,
thanks for the heads up. It was a typo. The post has been updated</description> <content:encoded><![CDATA[<p>Matt,</p><p>thanks for the heads up. It was a typo. The post has been updated</p> ]]></content:encoded> </item> <item><title>By: Matt</title><link>http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-142121</link> <dc:creator>Matt</dc:creator> <pubDate>Mon, 10 Dec 2007 23:49:05 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/howto-postfix-flush-mail-queue.html#comment-142121</guid> <description>The command for &quot;To remove all bounced mail from Queue, enter:&quot; is incorrect. That command will completely delete all the contents of your Mail Queue.
When I read this I thought it would eliminate only the bounced back emails that were sitting in my queue. I was wrong. It deleted all 6,000 of the emails sitting in my queue.
If this post is any sign of the type of information provided on this website, the readers are in for a big surprise...and some pink slips from their employer..</description> <content:encoded><![CDATA[<p>The command for &#8220;To remove all bounced mail from Queue, enter:&#8221; is incorrect. That command will completely delete all the contents of your Mail Queue.</p><p>When I read this I thought it would eliminate only the bounced back emails that were sitting in my queue. I was wrong. It deleted all 6,000 of the emails sitting in my queue.</p><p>If this post is any sign of the type of information provided on this website, the readers are in for a big surprise&#8230;and some pink slips from their employer..</p> ]]></content:encoded> </item> </channel> </rss>
