At 17:15 2010-01-12 +0200, Tony K Lindstrom wrote:
:0
* ^TO(testipelle|kestipelle|toberemoved)
{
ORIGTO=`formail -c -xTo:`
ORIGCC=`formail -c -XCc:`
Note that the case of the 'x' in these two lines is different. Given what
you're doing with the lines, you don't want to retain the header in that
second one. Further, you can extract BOTH headers at the same time and
combine them (since that's what you're doing anyway):
NEWCC=`(formail -c -xTo: -xCc:|tr -s '\n' ',')`
That should take the contents of To and Cc then replace newlines with
commas (eliminating multiple newlines, if any, before doing so). Try it at
a commandline. This will properly handle instances where a message has
more than one Cc: or To: header (which, while not common, is possible, and
can chuff up recipes like the one you have).
This is the stage where you might want to pipe the addresses through your
"scrubber", whatever you end up developing for that.
:0fhw
| formail -I "To: pelletesti(_at_)some(_dot_)com" -I "Cc: $ORIGTO,
$ORIGCC"
}
Here, you'd use the $NEWCC instead of the ORIGTO and ORIGCC stuff.
:0
* ^TOpelletesti(_at_)some(_dot_)com
! realman(_at_)some(_dot_)com
It does what it is supposed to do. If matching, it will move all
recipient addresses to the Cc: header, add a new To header and send it
to realman(_at_)some(_dot_)com(_dot_)
Why do you need to change the message to have the recipient as the
plaintext To? The headers are just for show and needn't be set any
particular way for the MTA to deliver a message.
But this is not enough. What I need now is a way to do the same as
above, but also remove all "toberemoved(_at_)some(_dot_)com" email-addresses
both
from TO and Cc headers.
Pipe the extracted addresses through sed.
The problem is of course, that the "toberemoved(_at_)some(_dot_)com" address
could
show in many different ways: "To Be Removed" <toberemoved(_at_)some(_dot_)com>
or
toberemoved(_at_)some(_dot_)com (To Be removed) or whatever.
Indeed.
---
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail