Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Server wide spam stop with qmail

by Aristotle (Chancellor)
on Jan 04, 2003 at 03:50 UTC ( #224188=note: print w/replies, xml ) Need Help??


in reply to Server wide spam stop with qmail

You can greatly simplify this by playing with the record separator. Something like the following:
#!/usr/bin/perl -w use strict; use Sys::Hostname qw(hostname); use Time::HiRes qw(gettimeofday); use Fatal qw(open close link unlink); use constant FORWARD => 0; use constant SUCCESS_DONTFORWARD => 99; my $maildir = '/var/spam'; # Maildir to store spam in. { local $/ = "\n\n"; $_ = <>; undef $/ my $body = <>; } exit !/^X-Spam-Flag:\s+YES/m ? print($_, $body), FORWARD : do { my $tph = join ".", time(), "$$\_".(gettimeofday)[1], hostname(); my $temp = "$maildir/tmp/$tph"; umask 007; # Name's Bond.. { open my $fh, ">", $temp; print $fh $_, $body; } link $temp, "$maildir/new/$tph"; unlink $temp; SUCCESS_DONTFORWARD; };
Untested..

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: Server wide spam stop with qmail
by Juerd (Abbot) on Jan 04, 2003 at 09:23 UTC

    undef $/ my $body = <>;

    E-Mail can be very large. Body includes attachments, so I prefer being slow over using a lot of memory.

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

      Ah, good point. In that case you might consider using, say, $/ = \32768; to read 32k chunks while printing the body - gets rid of the useless end-of-line scanning overhead.

      Makeshifts last the longest.

        you might consider using, say, $/ = \32768; to read 32k chunks while printing the body - gets rid of the useless end-of-line scanning overhead.

        Oh, that be a very good idea. *implements*

        Thanks!

        - Yes, I reinvent wheels.
        - Spam: Visit eurotraQ.
        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://224188]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2020-04-09 22:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The most amusing oxymoron is:
















    Results (49 votes). Check out past polls.

    Notices?