Delete Messages: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Unsupported}}{{ | {{BC|Community Sandbox}} | ||
__FORCETOC__ | |||
<div class="col-md-12 ibox-content"> | |||
=Delete Messages= | |||
{{KB|{{Unsupported}}|{{ZCS 6.0}}|{{ZCS 5.0}}|}} | |||
I stole this from vavai in the forums, but this is to delete messages from all queues that contain a certain e-mail address. I used it to delete all messages sent from a compromised account. | |||
You must run the mailq command as Zimbra. | You must run the mailq command as Zimbra. | ||
Line 76: | Line 81: | ||
</nowiki> | </nowiki> | ||
{{Article Footer|Zimbra Collaboration 6.0, 5.0|04/16/2014}} |
Latest revision as of 17:29, 11 July 2015
Delete Messages
I stole this from vavai in the forums, but this is to delete messages from all queues that contain a certain e-mail address. I used it to delete all messages sent from a compromised account.
You must run the mailq command as Zimbra.
su - zimbra mailq | more
Change password and locked/closed account only prevent new spam message. It doesn't remove queue message Use the following script to remove spam message from queue :
Save the following block as the command pfdel, set it as executable, then run it as specified in the top of the script.
#!/usr/bin/perl -w # # pfdel - deletes message containing specified address from # Postfix queue. Matches either sender or recipient address. # # Usage: pfdel <email_address> # 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 <email_address>\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 = <QUEUE>; # skip single header line $/ = ""; # Rest of queue entries print on # multiple lines. while ( $entry = <QUEUE> ) { 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 <$email_addr> " . "found in queue.\n"; } exit 0;