Skip to content

Postfix: Mails komfortabel löschen

Das folgende Skript löscht alle E-Mails aus der Mailwarteschlange, die dem als erstes Argument angegebenen regulären Ausdruck entsprechen:

#!/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);

Im folgenden Beispiel löscht man alle Nachrichten in der Warteschlange von oder zu der Domain "fuckspamdomain.com":
./postfix-delete.pl fuckspamdomain.com
Im folgenden Beispiel löscht man alle Nachrichten in der Warteschlange, die das Wort "xyz" in der E-Mail-Adresse enthalten:
./postfix-delete.pl xyz
Credits: nixcraft

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
BBCode format allowed
Form options

Submitted comments will be subject to moderation before being displayed.

cronjob