I think I have solved my own problem. Setting a variable plus using the
e flag in the default recipe should do it.
That's correct.
If you are following the procmail mailing list, I recently submitted
something along those lines. I neglected to mention previously that
when you redirect mail like this, the proper way is to use "Resent-To:"
and "Resent-Cc:".
Also, you keep saying (in your previous message) that "when their
address occurs on a Cc: header". What about if the mail is addressed
directly to you all? What about mail which has already been redirected
to you, by way of "Resent-To:" or "Resent-Cc:"?
To: fangchin, friend1, friend2
or:
To: friend1
Cc: fangchin
and other variations?
This recipe should handle all variations, and do the "Resent-To"
correctly.
ASPAN='(.*[^a-zA-Z0-9_.+-])?'
TOCC="^(Resent-)?(To|Cc):${ASPAN}"
RSTO RSCC
:0
* $ \/${TOCC}fangchin
{ :0
* MATCH ?? To
{ RSTO=fangchin(_at_)somewhereelse }
:0E
{ RSCC=fangchin(_at_)somewhereelse }
}
:0
* $ \/${TOCC}friend1
{ :0
* MATCH ?? To
{ RSTO="$RSTO friend1(_at_)newaddress1" }
:0E
{ RSCC="$RSCC friend1(_at_)newaddress1" }
}
:0
* $ \/${TOCC}friend2
{ :0
* MATCH ?? To
{ RSTO="$RSTO friend2(_at_)newaddress1" }
:0E
{ RSCC="$RSCC friend2(_at_)newaddress1" }
}
:0c # any forward To's or Cc's?
* 1^0 RSTO ?? .
* 1^0 RSCC ?? .
{ # fork another process so our message mucking doesn't mess up
# the current mail message in the main process
:0 # were there any To's?
* RSTO ?? .
{ RSADDR=`echo "$RSTO" | sed -e 's/^ //' -e 's/ /,/g'`
:0 fw
| formail -i"Resent-To: $RSADDR"
}
:0 # were there any Cc's?
* RSCC ?? .
{ RSADDR=`echo "$RSCC" | sed -e 's/^ //' -e 's/ /,/g'`
:0 fw
| formail -i"Resent-Cc: $RSADDR"
}
:0 # now deliver the mail as addressed by the Resent-To's
! $RSTO $RSCC
# This procmail child process should stop here, unless an
# error occurs.
HOST # guarantee that the child process exits
}