procmail
[Top] [All Lists]

Re: Procmail / Postfix Question

2010-01-20 21:26:15
At 19:12 2010-01-20 -0700, LuKreme wrote:
Procmail is an LDA (Local Delivery Agent). If you need to filter mails that is not destined for the local machine I think you will need a policy server. Unless you mean that it IS destined for a local user, but then you want to forward it to another email address.

I have aliases which deliver through an /etc/procmailrcs/ filter before forwarding. Virtusertable delivers specific addresses at specific domains to a domain-specific alias (so that the alias doesn't conflict with a local username or one from another hosted domain). Merely pass in a parameter which defines the address to forward to (and in my case, another parm which defines the alias itself -- the .nfg is merely a token I use so I can easily parse and separate).

drone.local-somedomain: "|/usr/bin/procmail -m /etc/procmailrcs/somedomain.rc \"drone.nfg fwdaddress(_at_)some(_dot_)other(_dot_)domain(_dot_)tld\""


somedomain.rc includes, in part:

# match regexp to obtain forwarding address
BLAT=$1
:0
* BLAT ?? \.nfg \/.*
{
        FWDADDR=$MATCH

        :0
        * BLAT ?? ^\/[-A-Z0-9_+(_at_)\(_dot_)]+\(_dot_)nfg
        * MATCH ?? ^^\/.+\.
        * MATCH ?? ^^\/([^.]|\.[^.])+
        {
                ALIAS=$MATCH
        }
}

:0:
* FWDADDR ?? ^^^^
${LOGBASE}problem.mbx

# grab the envelope sender
:0
* ^From \/[^    ]+
{
        # include the -f in front for using in sendmail invocation
        ENVFROM=-f$MATCH
}

#(various rules, some INCLUDERC'd from more generic configurations shared
# by multiple domains)


# ============================================================================
#
# If we reached this point, we'll be forwarding the message to the aliased
# recipient

# insert header identifying what alias this was processed for
:0fh
| formail -I"X-Somedomain: $ALIAS"

# If we've reached this point, simply forward the message.
# override the sender IF we grabbed an envelope sender
:0
!$ENVFROM $FWDADDR




(LOGBASE is defined to be the base name of the logfile used, but is also used for filing problem messages). Much of this recipe is prefixed by rules such as those which can be found in my sandbox (common header extractions, etc).

I'm using Sendmail, so can't offer specific advice about postfix, but the above should be doable.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

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