procmail
[Top] [All Lists]

How to extract multiple email addresses in To: header

2005-05-13 09:19:03
Can someone point me to a recipe that will extract pure email addresses
(not the text verbage) from the To and Cc headers.

For example,

To: Joe Schmoo <joe(_at_)schmoo(_dot_)com>, Bob Smith <bob(_at_)smith(_dot_)org>
Cc: Sam Spade <sam(_at_)spade(_dot_)com>

I want to end up with a procmail variable containing

joe(_at_)schmoo(_dot_)com, bob(_at_)smith(_dot_)org, sam(_at_)spade(_dot_)com

I see where the -rt of formail will flip the Sender address stripping
verbage.  However, I want the To line, not the From line.

Multigram might be of some assisance in this but I don't know how to
apply it.

The ^TO macro seems to have parsed this information out, but I'm not
sure how to apply this fact either.

The MATCH stuff in procmail is potent, and given an infinite amount of
time I might stumble onto a winning combination.

The FAQ mentions a non-trivial Sed script will probably do. Which
means something like

TOADDR = `$formail -zxTo:`
SEDTOADDR=`$echo $TOADDR | blah blah blah`

I can't be the first person that needs to accomplish this.
Has such a script ever been posted to the web, and if so, where ?

Any other comments or suggestions ?

Thanks in advance.

mark



____________________________________________________________
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