Remove Mail Queue in Postfix

To see mail queue, enter:
# mailq

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

mail.pl [script removed the mail queue as entered after the 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);

To run the script
./mail.pl xxx.com
‘or’
./mail.pl info@xx.com

Follow Me

Weather

Thimphu: 6° C

Condition: Mostly Cloudy

Sunrise: 7:12 am

Sunset: 8:46 pm

Time: 12:11:54 pm

Archives

Users: 5 Guests