procmail
[Top] [All Lists]

Re: Best way to extra To: address?

1999-02-12 10:06:11
On Fri, 12 Feb 1999, Lars Kellogg-Stedman wrote:

Howdy,

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

I use the following recipe to munge addresses to a smaller format before
forwarding messages to my pager:

  :0 c
  * ^Subject:.*urgent
  | sed -e '/^From:/ {s/ //;s/ .*//;s/<//;s/@.*//;s/$/@U/;}' \
        -e 's/^From:/From: /' | $SENDMAIL $PAGER_ADDR
         
The sed command does what you want, but unfortunately it also does more.
It replaces the domain with a U (since I don't want to waste characters
for the domain on my pager).  I know this script can be modified to do
what you want since I started out by writting a script which extracted the
address.  Unfortunately I no longer understand my own script, so the
modifications are up to you.  Perhaps removing 's/$/@U/;' will fix it.


-- Lars 
- Pat


<Prev in Thread] Current Thread [Next in Thread>