Tags

, , , ,

I found this particluar perl file very effective. This scripts give me the option to delete mail from the queue based on domain name or email id pattern. I have found this script in www.cyberciti.biz

$1>$1>


$1>

#!/usr/bin/perl

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

@data = qx/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);

Save this scripts and change the chmod to 755 (make the scripts executable). Now you can run the following command

./script.pl domain.com which will delete the domain.com mail from the mailq.
./script.pl xyz which will delete all queued messages that contain the word "xyz" in the e-mail address.

$1>