procmail
[Top] [All Lists]

Re: procmail/sendmail general filter question

1998-05-01 12:08:37
abeck(_at_)falcon(_dot_)org writes:
On Thu, 30 Apr 1998, Philip Guenther wrote:
to make a long story short, i've boned up on m4.. i like it :)
i've thrown this into my .mc file:

LOCAL_RULE_0
R$*<@$+>$*      $#procmail $@/etc/procmailrc $:$1(_at_)$2procmail$3
R$*<@$*.procmail>$*     $1@<$2>$3       map back of procmail copy

it puts it in S98.. 

Looks good.

Actually, I take that back.  You should not be using /etc/procmailrc as
the rule file, as that has another purpose in procmail.  Use
/etc/procmailrcs/something, or /etc/procmail.mailfilter, or something
else.  Just not /etc/procmailrc.


  # If you haven't extracted the envelope sender from $@ already:
  SENDER = $1
  SHIFT  = 1

what im wondering is, does it throw it into the right place, in regards to
using the above suggestion?  

Does what throw what where?  I'm not sure what the pronouns in the
above sentence are each refering to.

it was a continuation of the S98 question above, with the procmailrc
information thrown in as a reminder.. what Im asking is: you say "# If you
haven't extracted the envelope sender from $@ already:".. by putting those
procmail rulesets into S98, does that "conform" to the procmailrc
requirement that you listed? (again, the "before the enveloper sender is
extracted from $@)

The first of the two rules you've placed in LOCAL_RULE_0 calls the procmail
mailer.  The procmail mailer definition in sendmail automatically puts
the envelope sender at the beginning of the argument list passed to the
procmail command, so that procmail is called with something like:

    procmail -Y -m /path/to/procmailrc/from/the/rule envelope(_at_)sender \
            recipient(_at_)some(_dot_)where

Thus, in the procmailrc the envelope sender will be the first item in $@
and can be extracted from it via the two assignments from above.


the -exact- procmailrc i used to test that:


# If you haven't extracted the envelope sender from $@ already:
SENDER = $1
SHIFT  = 1

:0
* ^TObob(_at_)falcon(_dot_)org
! -f "$SENDER" -- "$@"
/var/adm/falcontest


Well, that last line is syntactically incorrect.  Procmail will just
skip it.  What are you trying to do?  Only allow through mail whose
header contains bob's address?  Only let through mail that's going to
bob?  (Those are different: consider a message from a mailing list to
which bob is subscribed.  It'll pass the latter but not the former.) If
you want to discard a message, just deliver it to /dev/null.  If you
want to refile a copy of the message, include a recipe with the 'c'
flag on it.  However, the last recipe in the procmailrc should not have
any conditions on it, and should either deliver to /dev/null (if you
want the default to be to discard the message) or resend the message
(if you want the default to be to let the message through).

Think of it this way: when procmail starts up, it *has* to deliver the
message in some way.  There is no default except the one _you_ put at
the bottom of the procmailrc.  To toss a message, deliver it to
/dev/null.  To pass a message on, use the following action:

        ! -f "$SENDER" -- "$@"


Philip Guenther