procmail
[Top] [All Lists]

Re: Forwarding mail on procmail error exit

1997-08-07 16:34:00
rik(_at_)netcom(_dot_)com (Rik Kabel) writes:
...
When I forward mail via procmail (! rik(_at_)hqgw(_dot_)company(_dot_)com), 
mail shows
up in MSMail with my login as the sender. I realize that this is a
result of MSMail looking at the envelope sender, and not at the From:
address.  When the original .forward file simply forwards all mail,
without invoking procmail, mail shows up with the proper sender.

This is because MSMail suffers from the critical limitation of only
having one sender address, unlike SMTP & rfc822's two, one for errors,
one for humans.  The Microsoft people made the choice to take the
former, the SMTP envelope address, as the sender address to use within
the MSMail system.  There are arguments both ways as to whether this is
better than taking the header address, so don't blame them for this but
rather for the original choice of only having one to start with.


To overcome this I thought of setting the .forward file to forward if
procmail fails, and force procmail to exit with an appropriate
ERRORCODE when I want a message forwarded.

This can't be done, as neither sendmail nor the shell understands the
idea of conditional addresses in .forwards.


...
The questions, then, are:

1) Can this be made to work, and if so, how? I suspect it can, I don't
know how.

You can do it from procmail by passing the -f option to the ! action
(a.k.a. sendmail).  You'll first have to choose what address to pass
into MSMail as the sender address.  Do you pass in the envelope
sender address, the header sender address, or perhaps the Reply-To:
address (if there is one)?  It's worse then it looks, because a message
can have multiple addresses in the From: field or Reply-To: field.
Which one do you take?

Note that with your original .forward file, you were getting the
envelope sender (visible on the UNIX-side and procmail in the
Return-Path:  header or the "From " pseudo-header).

Since there is no 100% correct solution, if I was faced with this situation,
I would probably choose to ignore the "multiple From:'s" problem, and
just go with whatever the From: field contains.  The key action is to
take whatever field you want, extract its value, then pass that to
sendmail via the -f option:

        # First, set the fallback-of-fallbacks
        MATCH = $LOGNAME

        # Now try to get a header.  First try for the From: header,
        # then the envelope sender, as found in the Return-Path:
        :0
        * ! ^From: +\/[^ ].*
        * ! ^Return-Path: +\/[^ ].*
        * ! ^From +\/[^ ]+
        { }

        :0
        ! -f "$MATCH" rik(_at_)hqgw(_dot_)company(_dot_)com


If you wanted to use the Reply-To: address when it exists, then just
insert it into the conditions on that first recipe:

        # First, set the fallback-of-fallbacks
        MATCH = $LOGNAME

        # Now try to get a header.  First try for a Reply-To:, then
        # the From: header, then the envelope sender, as found in the
        # Return-Path:
        :0
        * ! ^Reply-To: +\/[^ ].*
        * ! ^From: +\/[^ ].*
        * ! ^Return-Path: +\/[^ ].*
        * ! ^From +\/[^ ]+
        { }

        :0
        ! -f "$MATCH" rik(_at_)hqgw(_dot_)company(_dot_)com

If you always wanted to use the envelope sender like your original
.forward did, than you would take out the Reply-To: and From:
conditions and just try matching against Return-Path: and "From ".

Does that mess make sense?


Philip Guenther

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