<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Perl Archives - Vavai&#039;s Personal Notes</title>
	<atom:link href="https://www.vavai.net/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.vavai.net/tag/perl/</link>
	<description>Life is our precious gift</description>
	<lastBuildDate>Thu, 18 Oct 2018 13:00:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Bash Script for Spam Queue Removal on Zimbra Mail Server (Updated)</title>
		<link>https://www.vavai.net/bash-script-for-spam-queue-removal-on-zimbra-mail-server-updated/</link>
					<comments>https://www.vavai.net/bash-script-for-spam-queue-removal-on-zimbra-mail-server-updated/#respond</comments>
		
		<dc:creator><![CDATA[Muhammad Rivai]]></dc:creator>
		<pubDate>Thu, 18 Oct 2018 13:00:03 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mail Server]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Spam]]></category>
		<category><![CDATA[Zimbra]]></category>
		<guid isPermaLink="false">http://v2.vavai.net/?p=2036</guid>

					<description><![CDATA[<p>I have a small script-got it from Internet-for Zimbra spam queue removal based on Postfix queue message removal. The script written on Perl language and become a mandatory script on each Zimbra server deployment, as a quick tools to remove spam message from queue caused by compromised account. As of Zimbra 8.7, there is a little...</p>
<p>The post <a href="https://www.vavai.net/bash-script-for-spam-queue-removal-on-zimbra-mail-server-updated/">Bash Script for Spam Queue Removal on Zimbra Mail Server (Updated)</a> appeared first on <a href="https://www.vavai.net">Vavai&#039;s Personal Notes</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I have a small script-got it from Internet-for Zimbra spam queue removal based on Postfix queue message removal. The script written on Perl language and become a mandatory script on each Zimbra server deployment, as a quick tools to remove spam message from queue caused by compromised account.<br />
<figure id="attachment_2038" aria-describedby="caption-attachment-2038" style="width: 1280px" class="wp-caption alignnone"><img fetchpriority="high" decoding="async" class="wp-image-2038 size-full" src="http://54.254.121.108/wp-content/uploads/2018/10/phising.png" alt="" width="1280" height="977" srcset="https://d3b35uem336dgh.cloudfront.net/wp-content/uploads/2018/10/phising.png 1280w, https://d3b35uem336dgh.cloudfront.net/wp-content/uploads/2018/10/phising-300x229.png 300w, https://d3b35uem336dgh.cloudfront.net/wp-content/uploads/2018/10/phising-1024x782.png 1024w, https://d3b35uem336dgh.cloudfront.net/wp-content/uploads/2018/10/phising-768x586.png 768w" sizes="(max-width: 1280px) 100vw, 1280px" /><figcaption id="caption-attachment-2038" class="wp-caption-text">image from pixabay</figcaption></figure><br />
As of Zimbra 8.7, there is a little change on path for some Postfix binary. On previous version, Postfix binary located on <strong>/opt/zimbra/postfix/ </strong>but since version 8.7, the binary folder moved into <strong>/opt/zimbra/common/ </strong>so I take a little time to change the script.<br />
Below is an updated script, check for Zimbra version and change binary folder accordingly :<br />
[code lang=&#8221;bash&#8221;]<br />
#!/usr/bin/perl -w<br />
#<br />
# pfdel &#8211; deletes message containing specified address from<br />
# Postfix queue. Matches either sender or recipient address.<br />
#<br />
# Usage: pfdel sender-or-recipient-address<br />
#<br />
use strict;<br />
my $LISTQ;<br />
my $POSTSUPER;<br />
# Change these paths if necessary.<br />
system(&#8220;su &#8211; zimbra -c &#8216;zmcontrol -v&#8217; &gt; /tmp/zcs-ver.txt&#8221;);<br />
my $VER=`awk &#8216;/Release 6|Release 7|Release 8.0|Release 8.5|Release 8.6/&#8217; /tmp/zcs-ver.txt`;<br />
#print $VER<br />
if (length($VER) &gt; 0)<br />
{<br />
$LISTQ = &#8220;/opt/zimbra/postfix/sbin/postqueue -p&#8221;;<br />
$POSTSUPER = &#8220;/opt/zimbra/postfix/sbin/postsuper&#8221;;<br />
}<br />
else<br />
{<br />
$LISTQ = &#8220;/opt/zimbra/common/sbin/postqueue -p&#8221;;<br />
$POSTSUPER = &#8220;/opt/zimbra/common/sbin/postsuper&#8221;;<br />
}<br />
my $email_addr = &#8220;&#8221;;<br />
my $qid = &#8220;&#8221;;<br />
my $euid = $&gt;;<br />
if ( @ARGV != 1 ) {<br />
die &#8220;Usage: pfdel \n&#8221;;<br />
} else {<br />
$email_addr = $ARGV[0];<br />
}<br />
if ( $euid != 0 ) {<br />
die &#8220;You must be root to delete queue files.\n&#8221;;<br />
}<br />
open(QUEUE, &#8220;$LISTQ |&#8221;) ||<br />
die &#8220;Can&#8217;t get pipe to $LISTQ: $!\n&#8221;;<br />
my $entry = ; # skip single header line<br />
$/ = &#8220;&#8221;; # Rest of queue entries print on<br />
# multiple lines.<br />
while ( $entry = ) {<br />
if ( $entry =~ / $email_addr$/m ) {<br />
($qid) = split(/\s+/, $entry, 2);<br />
$qid =~ s/[\*\!]//;<br />
next unless ($qid);<br />
#<br />
# Execute postsuper -d with the queue id.<br />
# postsuper provides feedback when it deletes<br />
# messages. Let its output go through.<br />
#<br />
if ( system($POSTSUPER, &#8220;-d&#8221;, $qid) != 0 ) {<br />
# If postsuper has a problem, bail.<br />
die &#8220;Error executing $POSTSUPER: error &#8221; .<br />
&#8220;code &#8221; . ($?/256) . &#8220;\n&#8221;;<br />
}<br />
}<br />
}<br />
close(QUEUE);<br />
if (! $qid ) {<br />
die &#8220;No messages with the address &lt;$email_addr&gt; &#8221; .<br />
&#8220;found in queue.\n&#8221;;<br />
}<br />
exit 0;<br />
[/code]<br />
If you tend to lazy to copy-paste the script, get it from mine :<br />
[code lang=&#8221;bash&#8221;]<br />
wget https://www.vavai.com/pfdel<br />
chmod +x pfdel<br />
[/code]<br />
And to run it, just run this script with root permissions :<br />
[code lang=&#8221;bash&#8221;]<br />
./pfdel email-spammer<br />
[/code]<br />
ex :<br />
[code lang=&#8221;bash&#8221;]<br />
./pfdel spammersampah@vavai.com<br />
[/code]<br />
However, this is only a quick tools to remove spam, but more importantly is prevent spam from being filling into queue.</p>
<p>The post <a href="https://www.vavai.net/bash-script-for-spam-queue-removal-on-zimbra-mail-server-updated/">Bash Script for Spam Queue Removal on Zimbra Mail Server (Updated)</a> appeared first on <a href="https://www.vavai.net">Vavai&#039;s Personal Notes</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.vavai.net/bash-script-for-spam-queue-removal-on-zimbra-mail-server-updated/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Object Caching 27/46 objects using Disk
Page Caching using Disk: Enhanced 
Content Delivery Network via Amazon Web Services: CloudFront: d3b35uem336dgh.cloudfront.net
Lazy Loading (feed)
Minified using Disk
Database Caching 13/30 queries in 0.011 seconds using Disk

Served from: www.vavai.net @ 2026-12-04 18:02:47 by W3 Total Cache
-->