procmail
[Top] [All Lists]

Re: Sendmail rules

2000-10-27 10:02:58
"Carlos Perez Gonzalez" wrote:
as appears in procmailrc man page. These are my sendmail rules for my domain
in ruleset 0:

R$*<@hl.minaz.cu>$*
        $#procmail $@/etc/procmailrcs/antivirus.rc
        $:$1(_at_)hl(_dot_)minaz(_dot_)cu(_dot_)procmail$2
R$*<@$*.procmail>$*    $1<@$2>$3  Already filtered, map back

Carlos, as I received the mail from you, there were no TAB characters
in the above.  Sendmail is very particular about tabs vs spaces.

Here's an excerpt from "foo.cf" (I'm running version 8.9.3).  Watch
out for the tabs (there is one tab, but no spaces, before the '$
#procmail'; and there is one before the '$1<@$2>$3'; and there are
several tabs before 'Already filtered'):

================ begin excerpt of foo.cf
S0
R$*<@some.where.>$*
        $#procmail $@/etc/procmailrcs/some.rc 
$:$1(_at_)some(_dot_)where(_dot_)procmail$2

R$*<@$*.procmail.>$*
        $1<@$2>$3                               Already filtered, map back
================ end excerpt of foo.cf

I've also put this excerpt in an attachment.  It's encoded so that
tabs will not be destroyed.

Besides tab characters, please note that I've modified the rule (from
the manpage) by adding a '.' after 'some.where'.  This is because all
addresses pass through rule 3 before hitting rule 0 (at least I think
so).

Here's what I did to test it:

    1   $ /usr/sbin/sendmail -bt -C foo.cf -d18.21
    2   ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
    3   Enter <ruleset> <address>
    4   > 3,0 somebody(_at_)some(_dot_)where
    5   rewrite: ruleset   3   input: somebody @ some . where
    6   rewrite: ruleset  96   input: somebody < @ some . where >
    7   rewrite: ruleset  96 returns: somebody < @ some . where . >
    8   rewrite: ruleset   3 returns: somebody < @ some . where . >
    9   rewrite: ruleset   0   input: somebody < @ some . where . >
   10   rewrite: ruleset   0 returns: $# procmail $@ / etc / procmailrcs / some 
. rc $: somebody @ some . where . procmail
   11   > 3,0 somebody(_at_)some(_dot_)where(_dot_)procmail
   12   rewrite: ruleset   3   input: somebody @ some . where . procmail
   13   rewrite: ruleset  96   input: somebody < @ some . where . procmail >
   14   rewrite: ruleset  96 returns: somebody < @ some . where . procmail . >
   15   rewrite: ruleset   3 returns: somebody < @ some . where . procmail . >
   16   rewrite: ruleset   0   input: somebody < @ some . where . procmail . >
   17   rewrite: ruleset 199   input: somebody < @ some . where >
   18   rewrite: ruleset 199 returns: somebody < @ some . where >
   19   rewrite: ruleset  98   input: somebody < @ some . where >
   ... trimmed...

Notes:

    Line 1: -bt         -- means address test mode.  
            -C foo.cf   -- means use "foo.cf" instead of /etc/sendmail.cf
            -d18.21     -- will show us input and output of rulesets

    Line 4: I said 3,0 because addresses go through rule 3 before
            getting to rule 0.

    Line 9: Notice that ruleset 3 causes a '.' to be appended to the
            domain.  I originally started with the rule as shown in
            the manpage, and the output looked like this:

                > 3,0 foo(_at_)some(_dot_)where
                rewrite: ruleset   3   input: foo @ some . where
                rewrite: ruleset  96   input: foo < @ some . where >
                rewrite: ruleset  96 returns: foo < @ some . where . >
                rewrite: ruleset   3 returns: foo < @ some . where . >
                rewrite: ruleset   0   input: foo < @ some . where . >
                rewrite: ruleset 199   input: foo < @ some . where . >
                rewrite: ruleset 199 returns: foo < @ some . where . >
                rewrite: ruleset  98   input: foo < @ some . where . >

            "That's not right," I said.  "It's supposed to go to
            procmail before it ever sees rule 199!"  But I looked
            carefully at the input to ruleset 0:
                rewrite: ruleset   0   input: foo < @ some . where . >
            so of course it didn't match 
              R$*<@some.where>$*    (as shown in the manpage)
            and that's why I changed that line to be what you see in
            the attachment.

    Line 10: Here we see that it matched the rule; it will send the
             mail to the "procmail" delivery agent

    Line 11: Now let's see what happens, assuming that the procmail
             recipe sends the mail (as the example in the manpage
             does).  

    Line 17: We can see (compare with line 16) that the "already
             filtered, map back" rule has taken effect, and the mail
             will get sent out to <somebody(_at_)some(_dot_)where>

I hope this helps.  This logic has not been tested except what you see 
above, your results may differ, etc etc etc (sorry).

Regards,
collin
==========
Neither I nor my employer will accept any liability for any problems
or consequential loss caused by relying on this information.  Sorry.

S0
R$*<@some.where.>$*
        $#procmail $@/etc/procmailrcs/some.rc 
$:$1(_at_)some(_dot_)where(_dot_)procmail$2

R$*<@$*.procmail.>$*
        $1<@$2>$3                               Already filtered, map back
<Prev in Thread] Current Thread [Next in Thread>