Lars asked,
| Frequently, I want to extract just the user(_at_)host portion of the To:
address
| for use in my procmail recipes. That is, given something like this:
|
| To: Lars Kellogg-Stedman <lars(_at_)larsshack(_dot_)org>
|
| I just want:
|
| lars(_at_)larsshack(_dot_)org
| My current solution looks something like this:
|
| :0
| TO=|formail -I From -R To: From: | formail -rtzx To:
| Which works, but isn't all that pretty. Is there a better way?
I would have to say that nothing conveniently at hand for most procmail users
is as reliable for stripping comments from addresses as formail -rtzxTo:.
You could lower the overhead by feeing only the head to the first formail
and only the To: header to the second, and you could cut out the shell,
by doing this:
:0h
TO=| formail -iFrom: -R To: From: -X From: -s formail -rtzxTo:
or maybe some variation of Sean's suggestion will work, like this, using
only one formail call and no shell:
:0h
TO=| formail -iFrom: -R To: From: -X From: -rtzxTo:
but I couldn't get that to function.
Someone suggested using $MATCH, but that would end up invoking a shell:
:0i
* ^To:\/.+
TO=| echo "From: $MATCH" | formail -rtzxTo: