procmail
[Top] [All Lists]

Re: Extracting Email Address In From: Field

1997-05-29 13:13:00
On Wed, 28 May 1997, Stan Ryckman wrote:

I think my brain slipped out of gear and into neutral when I implied that
you could use just formail to do that. :-)

Don't feel bad, mine never made it into gear in the first place.;)


I forgot it might put out
the comments stuff as well as the address.  However, you can certainly
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

How would you add fields back to the header, like X-Loop after extracting 
the fields below with -X? 

        :0fw
        * ? test -s "$MEMBER_FILE"
        * ? fgrep -is "$WHOM" "$MEMBER_FILE"
        | ( formail -zk \
        -XDate: \
        -XFrom: \
        -XSubject: \
        ; cat -s $SIG_FILE )


avoid sed... use awk, perl, ...  :-)  Actually, with either awk or
perl you can probably do a 100% RFC822-compatible extraction since they
allow things like looping.  (I know, we're getting overly theoretical here,
and setting $MATCH as in the above quoted pattern will probably
meet your "real-life" needs anyway. :)


        FROM=`formail -zxFrom: | \
        sed -e 's/ *([^)]*) *//g' -e 's/.*<\([^>]*\)>.*/\1/g'`

I've been using the above recipe that Era posted for a few days now with
good luck.What kind of disadvantage is there in using sed compared to awk?
How would it be stated using awk? 


  * ^From:.*[  <]\/[^  <]*(_at_)[^  >]*

To replace the the sed script above to $MATCH, per your last recommendation, 
would I state it as:

        FROM=* ^From:.*[        <]\/[^  <]+(_at_)[^     >]+
                           ^^         ^^      ^^
             space & tabs here        here & here?

Regards,

Dave/Webmaster

    Sick And Tired Of SPAM? | Enjoy Great Humor?
         Join www.cauce.org | Join Joke-L
Hit SPAMMERS Where It Hurts | Listserv <listserv(_at_)ddave(_dot_)com>

           "So many SPAMMERS; so few comets."