Zimbra Mail Server Maintenance

download Zimbra Mail Server Maintenance

of 6

description

Zimbra Mail Server Maintenance Open source messaging and collaboration solution including full-featured email, calendar, address book, file sharing and tasks Zimbra Collaboration is an open source messaging and collaboration solution, trusted by more than 5,000 companies and public sector customers, and over 100 million end users, in over 140 countries. Zimbra includes complete email, address book, calendar, file-sharing and tasks, and can be accessed from the Zimbra Web client, MS Outlook, Mozilla Thunderbird and other standards-based email clients and mobile devices. You can deploy Zimbra as a traditional binary install on Linux or through one of our many Zimbra hosting providers.

Transcript of Zimbra Mail Server Maintenance

Delete Messages From Queue - WIKI Cautionary Note Warning, deleting messages from the queue can have a negative consequence of your users. You might need to account for the action and/or confirm your deletion was appropriate. Please try to save the postqueue -p information from the various messages prior to deleting them. This will at least you give you he information to later justify your actions on why you delete msg#. Relevant Sections Of Postsuper Man Page By default, postsuper(1) performs the operations requested with the -s and -pcommand-line options on all Postfix queue directories - this includes the incoming,active and deferred directories with mail files and the bounce, defer, trace and flushdirectories with log files.

-d queue_id Delete one message with the named queue ID from the named mail queue(s) (default: hold, incoming, active and deferred). If a queue_id of - is specified, the program reads queue IDs from standard input. For example, to delete all mail with exactly one recipient [email protected]:

mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } # $7=sender, $8=recipient1, $9=recipient2 { if ($8 == "[email protected]" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d -

Specify "-d ALL" to remove all messages; for example, specify "-d ALL deferred" to delete all mail in the deferred queue. As a safety measure, the word ALL must be specified in upper case.

Warning: Postfix queue IDs are reused. There is a very small possibility that postsuper deletes the wrong message file when it is executed while the Postfix mail system is delivering mail.

The scenario is as follows: 1) The Postfix queue manager deletes the message that postsuper(1) is asked to delete, because Postfix is finished with the message (it is delivered, or it is returned to the sender). 2) New mail arrives, and the new message is given the same queue ID as the message that postsuper(1) is supposed to delete. The probability for reusing a deleted queue ID is about 1 in 2**15 (the number of different microsecond values that the system clock can distinguish within a second). 3) postsuper(1) deletes the new message, instead of the old message that it should have deleted.

-h queue_id Put mail "on hold" so that no attempt is made to deliver it. Move one message with the named queue ID from the named mail queue(s) (default: incoming, active and deferred) to the hold queue.

If a queue_id of - is specified, the program reads queue IDs from standard input. Specify "-h ALL" to hold all messages; for example, specify "-h ALL deferred" to hold all mail in the deferred queue. As a safety measure, the word ALL must be specified in upper case. Note: while mail is "on hold" it will not expire when its time in the queue exceeds the maximal_queue_lifetime or bounce_queue_lifetime setting. It becomes subject to expiration after it is released from "hold".

-H queue_id Release mail that was put "on hold". Move one message with the named queue ID from the named mail queue(s) (default: hold) to the deferred queue.

If a queue_id of - is specified, the program reads queue IDs from standard input. Note: specify "postsuper -r" to release mail that was kept on hold for a significant fraction of $maximal_queue_lifetime or $bounce_queue_lifetime, or longer.

Specify "-H ALL" to release all mail that is "on hold". As a safety measure, the word ALL must be specified in upper case.

-p Purge old temporary files that are left over after system or software crashes.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 ALLAnother 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 deferredTo Delete Many Messages From QueueTo delete a large number of files one would use: /opt/zimbra/postfix/sbin/postsuper -d - < filename-with-queue-ids.txtThe filename, filename-with-queue-ids.txt example, would have a listing of id's like: 3E1C6CAFFFE6B862CC9D760BC38CC1BC990628CC6F3CE26B9CC3C6292A35CC943DA84BDBCE15DEA57CB1DF040F102CC74CB386E8CC4DFF92606CC0BDA0799FC8149A024CFCBD0DE2D30FC47DA031D85CC6308B8B3FC3DEBCAA4C7C913D0280F5CC8C6C9F341CC8A2693CD1B3B0EC433D0BF3716A1435CB4C382DB04CC911D56A29CC881911881C8268C5C050A79851C6739CC4BA511D3FCC7D098CBC0B20E0ADelete From Queue By Email AddressFrom CLIChange the [ [email protected] ] variable below first. To first see what would be deleted. As root: /opt/zimbra/postfix/sbin/postqueue -p | egrep -v '^ *\(|-Queue ID-' \| awk 'BEGIN { RS = "" } { if ($7 == "[email protected]") print $1} ' | tr -d '*!'To now delete, just include the postsuper -d at end: /opt/zimbra/postfix/sbin/postqueue -p | egrep -v '^ *\(|-Queue ID-' \| awk 'BEGIN { RS = "" } { if ($7 == "[email protected]") print $1} ' \| tr -d '*!' | /opt/zimbra/postfix/sbin/postsuper -d -Older example of what I had; the tail +2 was rhel4 specific To first see what would be deleted: mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($8 == "[email protected]" && $9 == "") print $1 } ' | tr -d '*!'To now delete, just include the postsuper -d at end: mailq | tail +2 | grep -v '^ *(' | awk 'BEGIN { RS = "" } { if ($8 == "[email protected]" && $9 == "") print $1 } ' | tr -d '*!' | postsuper -d -Script To Delete From Queue By Email AddressNon-Zimbra Script and not QA'd or tested. Path adjusted though for /opt/zimbra/postfix/sbin/* From http://www.ustrem.org/en/articles/postfix-queue-delete-en/ Save on file system, calling it something like - delete-queue-by-email.sh . Give it execute permission. Run as root. Example usage would be: ./delete-queue-by-email.sh [email protected] #!/usr/bin/perl -w## pfdel - deletes message containing specified address from# Postfix queue. Matches either sender or recipient address.## Usage: pfdel #

use strict;

# Change these paths if necessary.my $LISTQ = "/opt/zimbra/postfix/sbin/postqueue -p";my $POSTSUPER = "/opt/zimbra/postfix/sbin/postsuper";

my $email_addr = "";my $qid = "";my $euid = $>;

if ( @ARGV != 1 ) { die "Usage: pfdel \n";} else { $email_addr = $ARGV[0];}

if ( $euid != 0 ) { die "You must be root to delete queue files.\n";}

open(QUEUE, "$LISTQ |") || die "Can't get pipe to $LISTQ: $!\n";

my $entry = ; # skip single header line$/ = ""; # Rest of queue entries print on # multiple lines.while ( $entry = ) { if ( $entry =~ / $email_addr$/m ) { ($qid) = split(/\s+/, $entry, 2); $qid =~ s/[\*\!]//; next unless ($qid);

# # Execute postsuper -d with the queue id. # postsuper provides feedback when it deletes # messages. Let its output go through. # if ( system($POSTSUPER, "-d", $qid) != 0 ) { # If postsuper has a problem, bail. die "Error executing $POSTSUPER: error " . "code " . ($?/256) . "\n"; } }}close(QUEUE);

if (! $qid ) { die "No messages with the address " . "found in queue.\n";}

exit 0;

Script To Delete From Queue By Various Variable TargetsNon-Zimbra Script and not QA'd or tested. Path adjusted though for /opt/zimbra/postfix/sbin/* From http://jwcub.wordpress.com/2006/01/20/bulk-delete-from-postfix-queue/ Perl script called delete-from-mailq: #!/usr/bin/perl

$REGEXP = shift || die no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!;

@data = qx;for (@data) {if (/^(\w+)(\*|\!)?\s/) {$queue_id = $1;}if($queue_id) {if (/$REGEXP/i) {$Q{$queue_id} = 1;$queue_id = ;}}}

open(POSTSUPER,|/opt/zimbra/postfix/sbin/postsuper -d -) || die couldnt open postsuper ;

foreach (keys %Q) {print POSTSUPER $_\n;};close(POSTSUPER);Save the above script to a file say delete-queue.pl in your home directory, and make it excutable: chmod 755 delete-queueUsage - Run as root : Delete all queued messages from or to the domain iamspammer.com ./delete-queue iamspammer.com Delete all queued messages to specific address [email protected] ./delete-queue [email protected] Delete all queued messages that begin with the word bush in the e-mail address: ./delete-queue bush*\@whateverdomain.com Delete all queued messages that contain the word biz in the e-mail address: ./delete-queue biz

su - zimbrazimbra@mail:~$ zmmailbox -z -m [email protected] emptyFolder /Inbox