procmail
[Top] [All Lists]

Re: Return addresses

1997-06-27 09:58:00
Dennis A. Schmitz wrote:
bts8(_at_)netcom(_dot_)com wrote:

I'm trying to gather return addresses of people I regularly receive 

This is what I use. [...]

Ok, I refined it a little. You still have to prequalify the mail, but
once despammed, run it through this to gather friendly addresses:

Note that you must use 'sh' or 'ksh' or the sed line won't work.

# Anybody in the To: or CC: fields of a clean mail gets automatically
# added to the greylist if they are not already there.
 
SHELL=/bin/sh
LOGFILE=$HOME/.procmail.log
GreyList=$HOME/greylist
 
# explanation of this stuff: formail extracts fields from the header 
# and concantenates multiline headers. sed then strips quoted text
# (realnames), parened text (more realnames) and replaces commas with
# newlines, leaving raw email addresses one per line. It further strips
# <> brackets from email addresses and lastly removes all spaces. This
# raw list of email addresses is compared against the existing greylist
# and any lines not already in the list are appended to the list.
 
# known problem: when stripping the headers from a mail, multiple entries
# may appear (e.g. when from: and reply-to: are the same).
 
# todo find better way to eliminate dupes
 
# todo sort resultant list
 
:0 hc: addgrey.lock
| (formail -z -c -x from: -x reply-to: -x to: -x cc: | sed -e's/".*"//g' 
-e's/(.*)//g' -e's|,|\
|g' -e's/^.*<//' -e's/>.*$//' -e's/ //g' | grep -vwiF -f $GreyList >> 
$GreyList)

-- 
Dennis Schmitz                   email: den(_at_)lucent(_dot_)com

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