procmail
[Top] [All Lists]

Re: Extracting Email Address In From: Field

1997-05-29 13:13:00
At 11:30 AM 5/26/97 -0700, Dave/WebMaster wrote:
On Mon, 26 May 1997, Stan Ryckman wrote:
--
Cute.  But if you're willing to assume that email addresses have an "@"
in them and are well-behaved, wouldn't this work to set $MATCH with
no external process?:

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

(There should be a space and tab in each of the []'s, but this stupid
mailer won't put them in; I'm not on the shell machine at the moment.)

The whitespaces look fine from my end. It never occurred to me that I 
could match the 'From:' without an external process (no sarcastic 
remarks, please ;).

I don't see how... I didn't put any tabs in there, just a pair of
spaces.  Visually it may look OK, but if you cut and paste it, you
won't have tabs in there.

In looking at it again today, I'd change the last two "*" characters
to "+" on general principles, since "@" never begins or ends an
e-mail address.  Whatever.

[snip]

The match is not for a reply, but to compare the submitter's email addy 
against the memberlist and if they are on the no-cc list, don't send a cc.

I realized that... was just talking in terms of using the "reply" function
of formail to extract the "From:" header contents after stripping the
other headers it might use to generate replies.  Probably I wrote too
fast (but then *I* knew what I meant  :)

Can you think of a way to just use formail without sed?

I think my brain slipped out of gear and into neutral when I implied that
you could use just formail to do that. :-)  I forgot it might put out
the comments stuff as well as the address.  However, you can certainly
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. :)

Cheers,
Stan