procmail
[Top] [All Lists]

RE: Procmail at the MTA

2004-12-07 08:09:02

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.

Wow, that is an excellent idea.  I didn't realize you could specify a
mailertable entry like that.  Well, I guess its no different than using
smtp:[X.X.X.X], since smtp is defined as a mailer just like procmail is.


Seriously, thanks, that's a fantastic idea.  I'm going to give it a
shot.

Thanks,
Jon


__________________________________________________________________________

"The information transmitted is intended only for the person or entity to 
which it is addressed and may contain confidential, proprietary, and/or 
privileged material.  Any review, retransmission, dissemination or other 
use of, or taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is prohibited.  
If you received this in error, please contact the sender and delete 
the material from all computers."


____________________________________________________________
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>