procmail
[Top] [All Lists]

Re: Procmail at the MTA

2004-12-06 22:23:38
On Mon, 06 Dec 2004 12:19:05 -0600, Jon Dossey
<JDossey(_at_)deltahealthgroup(_dot_)com> wrote:

Can anyone recommend any software that will perform similar
functionality to Procmail, but at the MTA?  Possibly a configurable
milter interface?

If you're talking about milters, you're talking about sendmail ... and
it's certainly possible to have sendmail run messages through procmail
in the course of relaying.  In fact, this is exactly how procmail
expects to use the /etc/procmailrcs/ directory.

First you need to define the "procmail" mailer.  This is defined for
you by a number of preconfigured sendmail installations such as
RedHat's.  If it's not already defined, the usual way is to add

MAILER(procmail)

to your sendmail.mc, and rebuild the sendmail.cf file.

You'll use a mailertable entry to invoke this mailer, but before you
create it you should set up the procmail filtering.  I recommend using
/etc/procmailrcs/domainname as the file; e.g. if you're relaying for
the domain example.com you'd create /etc/procmailrcs/example.com. 
This file should end with a rule that forwards the mail to the
smarthost.  A caveat here is that you must change the domain-part of
the address to something that does not match the mailertable rule, or
else you'll have a mail loop.

The procmail mailer invokes procmail in such a way that $1 is the
envelope-from address and $2 is the envelope recipient.  Procmail is
inovked separately for each recipient if there is more than one, so
you shouldn't attempt to extract recipients from the message header. 
Instead, do something like:

------------
FROM="$1"
RCPT="$2"

# Whatever filtering rules you need go in the middle here

# Get the local-part of the address and tack on a new domain-part
:0
* RCPT ?? ^^\/[^(_at_)]+
{ RCPT="$MATCH(_at_)smarthost(_dot_)example(_dot_)com" }
:0 A
! -f "$FROM" "$RCPT"
------------

Next you need mailertable entry, usually added to /etc/mail/mailertable.

example.com:  procmail:/etc/procmailrcs/example.com

Rebuild the mailterable database with makemap as appropriate for your
sendmail config, and you're all set.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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