procmail
[Top] [All Lists]

Re: Almost crazy with sendmail + relay + procmail

2001-06-04 23:47:44
Adrian de los Santos <demon(_at_)deepgreen(_dot_)demon(_dot_)com(_dot_)mx> 
writes:
...
I want to setup some sendmail recipes on this mail hub so i can be
able to block certain senders and recipients.. and do other stuff ..

i enabled the local_procmail feature and add the following lines to
the S89 rule on the sendmail.cf

If you want to filter *all* domains, then you need to reverse the order of
the rules to prevent the loop.  There's actually more to it than that;
consulting a previous message on the subject and with some staring,
I believe the following should work:


LOCAL_CONFIG
CPprocmail procmaildot

LOCAL_RULE_0
R$+             $: $>procmail_filter $1

LOCAL_RULESETS
Sprocmail_filter
R$*<@$*.procmaildot.>$* $@ $1<@$2.>$3                   unwrap, preserving
R$*<@$*.procmail.>$*    $@ $1<@$2>$3                    a possible dot
R$*<@$*.>$*     $@ $#procmail $@/etc/procmailrc.master $: $1<@$2.procmaildot>$3
R$*<@$*>$*      $@ $#procmail $@/etc/procmailrc.master $: $1<@$2.procmail>$3

divert(-1)

(The procmaildot vs procmail bit is to preserve whether the original
host part was successfully canonicalized.)

That should go in your sendmail.mc file, of course, so you'll need to
regenerate your sendmail.cf from it after that.


...
SENDER = $1

To avoid problems with bounce message (where the sender is ""), you
should change that to:
        SENDER = "<$1>"


:0
* ^TO.(user(_at_)internet(_dot_)domain(_dot_)com)
* !^X-Loop: resend-ID
* !^FROM_MAILER
* !^FROM_DAEMON
| formail -A"Bcc: anotheruser(_at_)anotherdomain(_dot_)com" \
-A"X-Loop: resend-ID" | /usr/lib/sendmail -t

Rather than add a Bcc and then use sendmail -t, you should just put
the address on the sendmail command line:

        | formail -A"X-Loop: resend-ID" \
                | $SENDMAIL $SENDMAILFLAGS 
anotheruser(_at_)anotherdomain(_dot_)com


As is, that recipe will result in every message being delivered
twice, and if a mailing list is involved then a full loop may result.
sendmail -t should only be used when generating a *new* message where
you have control over the header.  This is true of auto-replies (formail
is generating the header), but not much else.


Philip Guenther
Procmail Maintainer
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>
  • Re: Almost crazy with sendmail + relay + procmail, Philip Guenther <=