procmail
[Top] [All Lists]

Re: Extracting Email Address In From: Field

1997-05-26 11:55:00
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 ;).


[more snip]

This can and will break with elaborate parenthesized comments in the
From: header -- RFC822 permits quite complicated expressions, although
in practice you rarely see anything other than the following three
variants:
 From: address(_at_)host(_dot_)domain(_dot_)com
 From: address(_at_)host(_dot_)domain(_dot_)com (I am the Walrus)
 From: The Walrus <address(_at_)host(_dot_)domain(_dot_)com>

Your sed script is more "rugged" than my $MATCH; mine won't work on
local users (no "@" in email address, typically) or on some
of the exceptions yours will catch such as
  From: "IAm(_at_)KoolDude" <address(_at_)whatever(_dot_)com>

The local users on the list have their full address in setup, so that 
shouldn't be a problem. I'll chastise anyone with an extra @ in the 
'From:' field.


But can't formail do it "right" anyway?  Make a copy of the
header, then strip out all reply headerfields except "From:", and
then generate FROM=`formail...` from the remainder (there will then
be nothing left *but* "From:" for formail to "reply" to)?
(Left as an exercise to the reader; not sure if it can be done
in one formail call; I'd probably end up using two  :)

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.

Can you think of a way to just use formail without sed? I can't get it to 
ignore everything in the 'From:' field except the email addy. It's a lot 
simpler just using the -r flag, but that won't work with a bounced message.

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."