Senin, 14 April 2014

Delete Queue Postfix With Spesific


Buat File Dengan nama delete.pl dengan isi sebagai berikut

#!/usr/bin/perl

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

@data = qx</usr/local/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);
 Lalu berikan permisi bisa dengan chmod 7777 or chmod -x
chmod 7777 delete.pl
 Jalan kan dengan cara sebagai berikut
delete.pl namedomain.com

 Jika Ingin menghapus dengan status Deferred
postsuper -d ALL deferred

 Jika Ingin menghapus semua queue mail di postfix
postsuper -d ALL
Categories:

0 komentar:

Posting Komentar