<?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/"
	xmlns:series="http://unfoldingneurons.com/"
		>
<channel>
	<title>Comments on: Quick Tip: 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>Sun, 21 Mar 2010 14:15:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<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>

<!-- Dynamic Page Served (once) in 0.181 seconds -->
