For example, say I have the following email addresses:
(ed(_at_)tv\(_dot_)com|joe(_at_)aol\(_dot_)com|hey(_at_)whats\(_dot_)happening\(_dot_)com)
I would like to check the To & Cc headers (plus resents) and see
what address is listed. If none is listed in either to or cc, then
I would like to check the Received: headers.
Before starting with a recipe, I should mention that this isn't a
bulletproof method. What about a Bcc? What if there are more than
two recipients (sendmail hides the address in the Received: headers
if that's the case)?
So this will catch some of it, but not all. And it doesn't account
for cases where multiple matching addresses are copied on a message;
it only uses the first match and adds that to your new header.
:0 fhw
*
^TO\/(ed(_at_)tv\(_dot_)com|joe(_at_)aol\(_dot_)com|hey(_at_)whats\(_dot_)happening\(_dot_)com)
| formail -A "X-Sent-To-Me-At: $MATCH"
$MATCH only matches on what's in your regular expression after the
\/ token. If you had changed your condition line to
*
^TO\/(ed(_at_)tv\(_dot_)com|joe(_at_)aol\(_dot_)com|hey(_at_)whats\(_dot_)happening\(_dot_)com).*
(note the trailing .*) then everything on the matching header after
your address would also be caught since it's now part of the regular
expression.
*
^TO\/(ed(_at_)tv\(_dot_)com|joe(_at_)aol\(_dot_)com|hey(_at_)whats\(_dot_)happening\(_dot_)com)
To: me(_at_)joebob(_dot_)com, joe(_at_)aol(_dot_)com,
everyone(_at_)example(_dot_)com
MATCH=joe(_at_)aol(_dot_)com
*
^TO\/(ed(_at_)tv\(_dot_)com|joe(_at_)aol\(_dot_)com|hey(_at_)whats\(_dot_)happening\(_dot_)com).*
To: me(_at_)joebob(_dot_)com, joe(_at_)aol(_dot_)com,
everyone(_at_)example(_dot_)com
MATCH=joe(_at_)aol(_dot_)com, everyone(_at_)example(_dot_)com
Chris