Subject: recipe to munge Reply-To

From: Nancy McGough <[email-masked]>
Date: Wed, 12 Apr 1995 14:40:34 -0700 (PDT)

Here's a recipe I just wrote to deal with something that has been
driving me crazy.  I use Pine's user-domain variable (set to ii.com)
to make it look like my mail comes from [email-masked] when in fact it
is coming from [email-masked].  But there's a problem: When I
receive mail from someone who's a halcyon user, Pine tries to respond
to [email-masked] rather than [email-masked].  This happens because
the From line just looks like this:

  From: user

I.e., there's no @halcyon.com in address.  Here's the recipe I wrote:

:0
* ! ^From:.*@
* ! ^Reply-To:.*@
{
 REPLYTO="`formail -rx To:[email-masked]"
 :0 fhw
 | formail -i"Reply-To:$REPLYTO"

 :0 a:
 IN.NoDomain
}

Once I feel like this is working, I'm going to change it to be just
the following so that the msg will continue through the rest of my
procmail recipes.

:0 fhw
* ! ^From:.*@
* ! ^Reply-To:.*@
REPLYTO="`formail -rx To:[email-masked]"
| formail -i"Reply-To:$REPLYTO"

And now my questions: 
 * Is there a better way to do this?
 * Do you foresee any problems with this?
 * Any style comments? 

Your feedback will help me to write a better Procmail FAQ which should
end up helping a lot of other people than just me.

Thanks much,
Nancy

---

From: [email-masked] (David W. Tamkin)
Date: Wed, 12 Apr 1995 23:26:39 -0500 (CDT)

Nancy McGough wrote,

| Once I feel like this is working, I'm going to change it to be just
| the following so that the msg will continue through the rest of my
| procmail recipes.
| 
| :0 fhw
| * ! ^From:.*@
| * ! ^Reply-To:.*@
| REPLYTO="`formail -rx To:[email-masked]"
| | formail -i"Reply-To:$REPLYTO"

| And now my questions: 
|  * Is there a better way to do this?

There has to be.  The way you wrote it won't work; you can't put an
assignment into the middle of a recipe.

|  * Do you foresee any problems with this?

Yes!  See above; also, it overlooks addresses in bang format and can be
fooled by an @-sign in the comment portion.

|  * Any style comments? 

Let's try this:

   :0h
   * ^(From|Reply-To):([^!%@]*(\(.*\))?|.*<[^!%@]*>)$
   REPLYTO=|formail -rzx To:
    :0Afwh
    | formail -i "Reply-To: [email-masked]"

If you're using an older version of formail that lacks the -z option,
leave it out (and drop the space after the colon in the last line).

In versions that support `??' you can write it more simply, but it would
mean running formail at least once on every incoming item, so it's not an
improvement:

  :0h
  REPLYTO=|formail -rzx To:
  
  :0fwh
  * ! REPLYTO ?? [!%@]
  | formail -i "Reply-To: [email-masked]"

David W. Tamkin  Box 3284  Skokie, Illinois  60076-6284
[email-masked]    MCI Mail: 426-1818   +1 312 714 5610