procmail
[Top] [All Lists]

Re: Procmail and sendmail.cf

2000-11-04 02:46:45
"Peter Parker" <petera(_at_)netstorm(_dot_)net> writes:
The sendmail.cf is basically unmodified from the redhat default, and from
what ive been reading in sendmail.cf FAQ's , by default $h just con
...
$h              Host part of the recipient address.

That's true for SMTP mailers, but it's just whatever the mailer needs it
to be.  In particular, the procmail mailer interprets $h as the name of
the rcfile to be used and when used as the local mailers, $h is just an
extra argument to be made availible to the user's .procmailrc.  It's all
just a set of conventions.


...
Now, example virtusertable entries

foo.com pete+%1
foo2.com pete+%2
foo3.com pete+%3

And the current .procmailrc im using

:0
| "/home/users/pete/mail.cgi" $1

I think you mean

        @foo.com        pete+%1
        @foo2.com       pete+%1
        @foo3.com       pete+%1


Hmm, why not do something like:

        @foo.com        pete+%1+foo.com
        @foo2.com       pete+%1+foo2.com
        @foo3.com       pete+%1+foo3.com
        +*(_at_)foo(_dot_)com   pete+%1+%2+foo.com
        +*(_at_)foo2(_dot_)com  pete+%1+%2+foo2.com
        +*(_at_)foo3(_dot_)com  pete+%1+%2+foo3.com

That'll pass not just the username, but the domain, appended with a
'+'.  Then, in pete's .procmailrc, you just need to parse $1 to extract
the two parts, which you then put back together with an '@' between
them.  The last three entries above let you pass through +detail
addresses for the virtual domains, though your sendmail should be at
least version 8.10.1 for that to work.

Anyway, the top of the rcfile would need to look something like:

        # Copy $1 into the ARG variable so that we can match against it
        ARG = $1

        # Extract everything in ARG before the final plus.  This requires
        # two matches because there may be more than one plus in it if
        # a +detail address was used with a virtual domain user.  The
        # second condition matches against the result of the first match's
        # extraction.  It looks strange, but it's the easiest way.
        :0
        * ARG   ?? ^^\/.+\+
        * MATCH ?? ^^\/.*[^+]
        {
            localpart = $MATCH
        }

        # everything after the last plus is the domain
        :0
        * ARG ?? ()\+\/[^+]+^^
        {
            domain = $MATCH
        }

        :0 w
        | $HOME/mail.cgi "$localpart(_at_)$domain"


Note that by using $HOME instead of hardcoding the path, I've made the
above rcfile generic enough that you could use the same file with
multiple accounts.


Philip Guenther
_______________________________________________
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>