Re: Bounce TTL versus non-bounce TTL

(no email)
Date: Sun Feb 02 2003 - 14:46:40 EST


On Sun, 2 Feb 2003, Simon White wrote:

> For the deferred / bounce queues a simple PERL based parser might be
> useful though.
>

Since operating on the resulting queued messages requires privileges, it
is enough IMHO to forgo the protocol entirely and directly (in Perl) parse
the underlying queue files. I have some tools along these lines, and
have recently posted the core queue file parsing code to this list.

Since it is so short here it is again:

sub rec_get {
    my ($h) = @_;
    my $r = getc($h) || return;
    my $l = 0;
    my $shift = 0;
    while (defined(my $lb = getc($h))) {
        my $o = ord($lb);
        $l |= ($o & 0x7f) << $shift ;
        last if (($o & 0x80) == 0);
        $shift += 7;
        return if ($shift > 7); # XXX: max rec len of 4096
    }
    my $d;
    return unless ($l == 0 || read($h,$d,$l) == $l);
    ($r, $l, $d);
}

sub qenv {
    my ($qfile) = @_;
    my $h = new IO::File($qfile, "r") || return;
    my ($t, $s, @r);
    while (my ($r, $l, $d) = rec_get($h)) {
        push(@r, $d) if ($r eq "R");
        $s = $d if ($r eq "S");
        $t = $d if ($r eq "T");
        last if ($r eq "M");
    }
    close($h);
    ($t, $s, @r);
}

The qenv() routine does not correctly process messages submitted via "sendmail
-t", since these have recipients after the message body, such messages are
not present on the gateway system where I use the code. Extending the code
to deal with "extracted" recipients is left as an exercise for the
reader (of this message and the Postfix source code)...

-- 
	Viktor.







Hosted Email Solutions

Invaluement Anti-Spam DNSBLs



Powered By FreeBSD   Powered By FreeBSD