procmail
[Top] [All Lists]

Re: Picking Off Sender's Address

1997-06-29 15:28:00
On Sun, 29 Jun 1997 20:43:41 +0300 (EET DST), I wrote:
The canonical way to get formail to strip an address down to just the
email terminus (i.e. user(_at_)domain) is

    formail -rtzxTo:

but this is not guaranteed to always pick the From: address for a
reply address (it will grab Reply-To instead if it's there, etc).

Stephen, would it be possible to implement, say, a -Z switch which
says, pare all address fields down to just the e-mail terminus? 

I tried to look at the formail code and see how this could be
implemented but it doesn't look really trivial to patch in (and I
wouldn't trust myself to write anything more complicated than "Hello
World" in C anyway). 

The -Z is in analogy with -z which canonicalizes fields another way.
I'd imagine you could use the list in the sest array for what fields
to process. 

Perhaps the robustness of the parsing of addresses could be improved a
little bit at the same time.

With this, you could say, e.g., 

    formail -ZxFrom:

to always extract the From: field, and

    formail -Z -xFrom: -xReply-To: -xSender: # etc

to get a nice list of usual suspects to feed to  | fgrep bozos ,and

    formail -Z

to trim all address fields down to just the terminus.

What do you think? 

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>