When Era Eriksson suggested,
| > SENDER=`formail -rtzx To:`
Jim Dennis responded,
| This is neat! As an experiment
| I just ran this command on a few old folders:
|
| formail -s formail -rtzx To: < $oldfolder | sort -u
As Era has already posted (but I don't want to overlook the point), it is
more efficient to do it this way:
formail -rtzx To: -s < $oldfolder | sort -u
| ... and it builds a list of people and lists which have
| sent me mail.
Not exactly; it builds a list of return addresses of the mail you've
received. The return address of a letter is not always the same as the
sender's address. In fact, I think it's better to use a variable name
such as REPLY_TO or REPLYADDR rather than SENDER for `formail -rtzx To:`.
A good way to get the *sender* of a letter might be like this:
:0 # on first matching regexp, condition fails and we go to Else clause
* ! Resent-Sender: *\/[^ ].*
* ! Resent-From: *\/[^ ].*
* ! Sender: *\/[^ ].*
* ! From: *\/[^ ].*
* ! Return-Path: *\/[^ ].*
* ! From *\/[^ ]*
* ! Resent-Reply-To: *\/[^ ].*
* ! Reply-To: *\/[^ ].*
* ! Return-Receipt-To: *\/[^ ].*
{ SENDER=nobody } # no usable sender info in header
:0E
{ RAWSENDER=$MATCH # as set in first recipe
# now strip out comments
:0 # Real Name <user(_at_)site(_dot_)dom(_dot_)ain>
* RAWSENDER ?? ()> *$
* RAWSENDER ?? ()<\/[^>]*
{ SENDER=$MATCH }
:0E # user(_at_)site(_dot_)dom(_dot_)ain (Real Name)
* RAWSENDER ?? ()\) *$
* RAWSENDER ?? ^^\/[^ (]*
{ SENDER=$MATCH }
:0E # otherwise
{ SENDER=$RAWSENDER }
}