To clean the queue for specific domain:

First create a perl script:

#############################

#!/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,”|cat”) || die “couldn’t open postsuper” ;

open(POSTSUPER,”|postsuper -d -“) || die “couldn’t open postsuper” ;

foreach (keys %Q) {

print POSTSUPER “$_\n“;

};

close(POSTSUPER);

#########################################

 

 

Usage Examples:

Delete all queued messages to or from the domain called spamers.com, enter:

./postfix-delete.pl spamers.com

Delete all queued messages that contain the word “spam” in the e-mail address:

./postfix-delete.pl spam

 

Clean up the inbox

We can clean the inbox in two ways:

  1. Command:
mail -N
d *
quit

2. simply delete the /var/mail/username file