procmail
[Top] [All Lists]

Re: bozolog doesn't work

1997-03-22 03:26:01
On Fri, 21 Mar 1997 22:29:02 +0100 (CET),
Robin S Socha <uzs8kb(_at_)uni-bonn(_dot_)de> wrote:
I've been trying to tweak two recipes into one, but there seems to be a
simple mistake that prevents the second one from being executed.

The way I analyze this (without any log excerpts etc) is that Procmail
considers the message delivered after the first recipe succeeds. You
need to use the "c" flag on the first recipe to force subsequent
recipes to continue even if this one succeeds in delivering the mail.
In other words, after saving something to "BOZOLOG", Procmail
concludes that it's done; adding the "c" flag will make it continue
with a copy of the message. 

Other problems: You should perhaps be locking BOZOLOG. But the whole
idea to pipe into a bunch of "echo" statements is a little bit flawed,
IMHO; you should probably use the LOG facility instead. (OTOH, this
will still leave BOZOLOG without a lock so you might get interspersed
writes in the log if two Procmails try to write to it at the same
time.)

Below is my attempt at a reimplementation. 

BOZOFILE=$HOME/.list-of-bastards     # Reject addresses containing
                                     # any string in this file.
BOZOLOG=$HOME/.bozolog                       # Where to log rejects
BOZODEST=$HOME/Mail/rejected         # Where to send rejects
TEST=${TEST:-/usr/bin/test}
FORMAIL=${FORMAIL:-/usr/bin/formail}
FGREP=${FGREP:-/usr/bin/fgrep}
ECHO=${ECHO:-/bin/echo}
DATE=${DATE:-/bin/date}

These look OK. (I save rejects to a file in a temp directory so as not
to have them litter my precious quota. The temp directory gets swiped
occasionally; if you use /tmp, that is cleared out whenever the
machine is rebooted, but your admin might want you to use some other
directory.) 

FROM=`$FORMAIL -zx "From:"`

You might want FROM=`$FORMAIL -rt -xzTo:` here, otherwise not much
sense in calling up Formail. The modified version will construct a
reply with the correct reply address based on information in From:,
Reply-To:, Sender: etc in the original, and then extract the "To:"
address from the generated reply.

(If you don't want this, you can do the original entirely within
Procmail itself and save a process:

:0
* ^From:[       ]*\/[^   ].*
FROM=$MATCH

The whitespace inside the brackets consists of a space and a tab.)

:0
* ? $TEST -f $BOZOFILE
* FROM ?? ? $FGREP -f $BOZOFILE
{

This is fine, and pretty advanced. 

     :0
     | ( $ECHO "bozo: [`$DATE`] rejected message from '$FROM'"; \
         $ECHO "bozo: (message dumped to $BOZODEST)" ) >> $BOZOLOG

How's this (untested):

        OLDLOG=$LOGFILE
        LOGFILE=$BOZOLOG
        LOG="bozo: [`$DATE`] rejected message from '$FROM'
bozo: (message dumped to $BOZODEST)
"
        LOGFILE=$OLDLOG

     :0
      | $MAILDIR/forrep $MAILDIR/standard_disclaimer \
      | $FORMAIL -i "Subject: Thank you for your mail, but...." \
      | $SENDMAIL -oi -t

This should work now. 

}
FROM

This will unset FROM, is that what you want?

If you still have problems, a log file snippet would be nice. 

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

<Prev in Thread] Current Thread [Next in Thread>