On Fri, May 13, 2005 at 10:55:29PM +0200, Dallman Ross wrote:
On Fri, May 13, 2005 at 10:47:08AM -0500, mark david mcCreary wrote:
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 had sent a couple of refinements of my procmail-only solution
and thought I was done with this thread. But I just tried out
the rcfile I concocted and found it looping endlessly because
of a bug in my algorithm having to do with placing the SWITCHRC
in a place where it can trigger unconditionally. Here is one
final posting of the solution with that bug fixed.
Btw, with this version, one can preset ${_ifs} to something else,
such as $NL, $SPACE, `|', or whatever, and generate output
so separated instead of by ` ,'.
####################### start rcfile "get-addies.rc" #######################
LINEBUF = 24000
:0
* HDRFLD ?? ^^()^^
{
SPACE = ' '
TAB = ' '
_ifs = ${_ifs:-,$SPACE}
HOSTCL = [a-zA-Z0-9-]
AHOST = ($HOSTCL+[.])*$HOSTCL+
ADDYCL = "[^]><)([$SPACE$TAB,;:\"'@]"
HDRFLDNAME = ${HDRFLDNAME:-To}
:0
* $ ^$HDRFLDNAME:.*\/[^$SPACE$TAB].*
{ HDRFLD = $MATCH _HOLD = $HDRFLD }
}
:0
* $ _HOLD ?? ()\/$ADDYCL+(_at_)$AHOST[(_dot_)][a-zA-Z]+
{
ADDRESS = $MATCH
STRIPPED_ADDRESSES =
${STRIPPED_ADDRESSES:+$STRIPPED_ADDRESSES${_ifs}}$ADDRESS
:0
* $ _HOLD ?? $\ADDRESS\/.+
{
_HOLD = $MATCH
SWITCHRC = $_
}
} _HOLD HDRFLDNAME _ifs ADDRESS # unset unneeded local vars
LOG = "Stripped addresses: >$STRIPPED_ADDRESSES<
"
######################## end rcfile "get-addies.rc" ########################
--
dman
____________________________________________________________
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