procmail
[Top] [All Lists]

Re: changing headers upon forwarding

2003-09-09 11:03:58
Nikolaus Hiebaum asked:

I forward the e-mails arriving at account#1 to account#2. Sometimes,
however, the host of account#2 is down for some time and the senders of
e-mails get an error message. People don't know about account#2 and
shall not, and the whole thing of receiving a bounce from an address
they don't know with an e-mail addressed to me confuses them.

You are absolutely right. When you forward mail, and the destination address is unreachable, bounces should come to the forwarding point, not to the original sender.

By default, procmail's "!" operator does the right thing, because it rewrites the envelope sender for the forwarding leg of the trip.

So, I thought of adding a Reply-To: address to forwarded e-mails, which
should act as a "collector" for any error bounces.

Er, no. Bounces don't come to Reply-To:, unless the rejecting system is very badly misconfigured. They come to Return-Path:; that's what the return path is for.

Version 1:
:0 c
* !^X-Loop: name(_at_)account1\(_dot_)com
| (formail -rI "Reply-To: name(_at_)account1(_dot_)com" \
        -A "X-Loop: name(_at_)account1(_dot_)com") | ! 
name(_at_)account2(_dot_)com

Not "| !"; use "| $SENDMAIL name(_at_)account2(_dot_)com" instead. Also, leave out the Reply-To:, because if you do read it at account2, you'll want to send your response to the writer, not to your own address on account1 (which will just give it back to you at account2 anyway). And you don't want to use formail's -r option there!

 :0 c
 * !^X-Loop: name(_at_)account1\(_dot_)com
 | (formail -A "X-Loop: name(_at_)account1(_dot_)com") | \
    $SENDMAIL name(_at_)account2(_dot_)com

Version 2:
:0
* !^X-Loop: name(_at_)account1\(_dot_)com
{
    :0
    | (formail -I "Reply-To: name(_at_)account1(_dot_)com" \
        -A "X-Loop: name(_at_)account1(_dot_)com")

    :0 c
    ! name(_at_)account2(_dot_)com
}

Add the `f' flag (and `h' would help too) to the recipe that invokes formail (and you don't need the parentheses) and, as I said above, take out the Reply-To: part.

 :0
 * !^X-Loop: name(_at_)account1\(_dot_)com
 {
     :0hfw
     | formail -A "X-Loop: name(_at_)account1(_dot_)com"

     :0 c
     ! name(_at_)account2(_dot_)com
 }

Arguably, you might want to do this instead and do the whole thing on a copy of the message in a clone of the procmail invocation instead of using a copy only for the forwarding (I wouldn't, personally):

 :0c
 * !^X-Loop: name(_at_)account1\(_dot_)com
 {
     :0hfw
     | formail -A "X-Loop: name(_at_)account1(_dot_)com"

     :0
     ! name(_at_)account2(_dot_)com
 }

It depends on whether you want the locally delivered copy at account1 to show the X-Loop: header or not. I would want it to, so I wouldn't go the cloning route.


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