procmail
[Top] [All Lists]

Re: Space insertion in header lines

1997-06-25 17:00:00
Robert Gahl <bgahl(_at_)thesphere(_dot_)com> writes:
Philip Guenther <guenther(_at_)gac(_dot_)edu> writes:
How refreshing: a virtual domain setup that can actually work!
You should, however, remove the 'm' flag from the F= directive.
They fixed the default in sendmail 8.8.6 (released recently).

I'm running 8.8.5 currently. Does the above mean "remove it for
8.8.5 and any subsequent releases" or "leave it until you upgrade
to 8.8.6, and then remove it."?

Remove it for all releases.  Unless you know exactly what you're doing,
the 'm' flag on the procmail mailer makes thing _very_ difficult to
do correctly.  See below.


You're still routing the message based on the header address(es),
instead of the envelope address which sendmail is nicely passing
to procmail as $2.  ($1 contains the envelope sender.)  Actually,
matching on the "for" clause of the Received: lines will often
work, as, if it exists, it will contain the envelope recipient.
You're better of doing this instead, as it will always work:

     RECIPT = $2

     :0
     * RECIPT ?? ^^username@
     ! username(_at_)pop(_dot_)otherdomain(_dot_)com

This puts the recipient in a variable that can be matched against using
the "var ??" condition special.  The double caret (_not_ carat) will
keep this from matching the address "anotherusername(_at_)domain(_dot_)com". 
 Don't
worry about matching the domain: since only stuff to domain.com will
reach here, you don't need to check it.  If you had multiple mailertable
entries pointing at the same procmailrc then you would want to match
that part as well.

Most of my problem is, admittedly, sendmail here. What I want procmail
to do is blazingly simple. What happens to RECIPT in the above recipe
when the To: contains multiple recipients, all at the domain in
question? Does procmail split this into one mail message per recipient,
whether or not it is a To:, Cc:, or Bcc: ?

It sounds really odd, but YOU DON'T CARE WHAT'S IN THE To:, Cc:, OR
Bcc:  FIELDS.  In fact, unless you give it the -t flag, sendmail
doesn't really care either (it'll rewrite them, but it'll ignore them
when determining whom to send to).  What you care about is what
appeared in the RCPT TO:  SMTP command.  For each of those (the
envelope recipients), sendmail will process the address through ruleset
0 to determine which mailer should be used to send to that address.  If
it comes up with the procmail mailer (via that mailertable entry)
sendmail will invoke the procmail, passing *that address* on the
command line, to show up as $2 in the procmailrc.

If there were multiple recipients to be delivered to via the procmail
mailer, sendmail will invoke procmail once for each, because you
removed the 'm' flag from the mailer definition.  If you didn't,
sendmail would do all of them at once, and you would have to do the
iteration inside procmail, which requires recursive INCLUDERCs.  If
you're a lisp/scheme hacker it's not _too_ difficult to grok, but it's
not really worth the effort unless, like me, you're a freak.

To summarize, if you remove the 'm' flag from the mailer, sendmail will
handle the iteration through possible multiple recipients.  If not, you
have to handle it inside procmail with considerable more work.

Philip Guenther

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