Site icon Learning & Doing

Zimbra & Postfix Command

To stop and start postfix, amavis, and clam [as the zimbra user] :

zmmtactl stop
zmmtactl start

To See The Postfix Queues

As zimbra using sudo – show a summary of queue count – ~/libexec/zmqstat:

[zimbra@mail37 ~]$ sudo ~/libexec/zmqstat
hold=0
corrupt=0
deferred=0
active=0
incoming=0

As zimbra – /opt/zimbra/postfix/sbin/postqueue -p

[zimbra@mail37 ~]$ /opt/zimbra/postfix/sbin/postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
EC753D0D00*     328 Thu Apr  5 14:34:09  sender@sourcedomainname.local
                                         recipient@destinationdomainname.local

-- 0 Kbytes in 1 Request.

As zimbra – mailq

[zimbra@mail37 ~]$ mailq
Mail queue is empty

Qshape – Print Postfix queue domain and age distribution

/opt/zimbra/bin/qshape


o View A Message In The Queue

Get the message id and use post cat:

/opt/zimbra/postfix/sbin/postcat -q EC753D0D00

or with more information, include the -v option:

/opt/zimbra/postfix/sbin/postcat -qv EC753D0D00

To Flush Postfix Queue

/opt/zimbra/postfix/sbin/postqueue -f

To Requeue Messages In Postfix

/opt/zimbra/postfix/sbin/postsuper -r ALL

To Delete Single Message From Queue

/opt/zimbra/postfix/sbin/postsuper -d [MSGID From postqueue -p]

To Delete ALL Messages From Queue

/opt/zimbra/postfix/sbin/postsuper -d ALL

Another way to do this:

mailq | awk \'{print $1}\' | postsuper -d -

To Delete ALL Messages From The Deferred Queue

/opt/zimbra/postfix/sbin/postsuper -d ALL deferred

To Delete ALL Messages From The Hold Queue

/opt/zimbra/postfix/sbin/postsuper -d ALL hold

To Delete Many Messages From Queue

To delete a large number of files one would use:

/opt/zimbra/postfix/sbin/postsuper -d - < filename-with-queue-ids.txt

Postfix Flush the Mail Queue

following command to flush the mail queue:
# postfix flush
OR
# postfix -f

To see mail queue, enter:
# mailq

To remove all mail from the queue, enter:
# postsuper -d ALL

To remove all mails in the deferred queue, enter:
# postsuper -d ALL deferred

postfix-delete.pl script

Following script deletes all mail from the mailq which matches the regular expression specified as the first argument (Credit: ??? – I found it on old good newsgroup)

#!/usr/bin/perl
 
$REGEXP = shift || die "no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!";
 
@data = qxusr/sbin/postqueue -p>; for (@data) { if (/^(\w+)(\*|\!)?\s/) { $queue_id = $1; } if($queue_id) { if (/$REGEXP/i) { $Q{$queue_id} = 1; $queue_id = ""; } } }   #open(POSTSUPER,"|cat") || die "couldn't open postsuper" ; open(POSTSUPER,"|postsuper -d -") || die "couldn't open postsuper" ;   foreach (keys %Q) { print POSTSUPER "$_\n"; }; close(POSTSUPER);

For example, delete all queued messages from or to the domain called fackspamdomain.com, enter:
./postfix-delete.pl fackspamdomain.com
Delete all queued messages that contain the word “xyz” in the e-mail address:
./postfix-delete.pl xyz

 

# Bisa menggunakan qshape

install

yum groupinstall perl development
yum install postfix-perl-scripts

 

#qshape

#qshape deferred
#qshape active
#mailq
 
Exit mobile version