Re: [Exim] delivery for frozen mails

Góra strony
Delete this message
Reply to this message
Autor: Sheldon Hearn
Data:  
Dla: Suresh Ramasubramanian
CC: exim-users
Temat: Re: [Exim] delivery for frozen mails

On Fri, 29 Jun 2001 16:17:33 +0530, Suresh Ramasubramanian wrote:

> The way to go would be
>
> exim -Mrm `mailq|grep \<\>|cut -c 11-27`
>
> [assuming you want to get rid of _all_ bounces in your queue]


I find the following Perl5 script useful. It allows me to strip
recipients from messages, given a sender pattern and a recipient
pattern. If it strips a recipient address from a message that is
frozen, the message is thawed.

Sometimes, this script will leave messages on the queue with no
recipient addresses, but the next queue run catches them, so it's not a
real issue for me.

To achieve the example you gave above, you'd use:

    exim_striprecip "" ".*"


Ciao,
Sheldon.

--------
#!/usr/bin/perl -w

use strict;

my $PROGNAME = "exim_striprecip";
my $EXIM_PATH = "/usr/local/sbin/exim";

my ($line, $match_recip, $match_sender);

if (not defined($ARGV[0]) && defined($ARGV[1]) && !defined($ARGV[2])) {
    die "usage: $PROGNAME sender_addr_regex recip_addr_regex\n";
}
$match_sender = $ARGV[0];
$match_recip = $ARGV[1];


open(QUEUE, "$EXIM_PATH -bp |");

$line = <QUEUE>;
OUTER: while ($line) {
    my ($frozen, $msg_id, $recip, $sender);


    if ($line !~ / ([a-zA-Z0-9-]+) <($match_sender)>( \*\*\* frozen|)/) {
        $line = <QUEUE>;
        next;
    }


    ($msg_id, $sender, $frozen) = ($1, $2, $3);
    $line = <QUEUE>;
    while ($line !~ /<.*>/) {
        if ($line =~ /  \b($match_recip)$/) {
            $recip = $1;
            system("$EXIM_PATH -Mmd $msg_id $recip");
            if ($frozen) {
                system("$EXIM_PATH -Mt $msg_id");
                $frozen = 0;
            }
        }
        if (not $line = <QUEUE>) {
            last OUTER;
        }
    }
}