procmail
[Top] [All Lists]

Re: Picking Off Sender's Address

1997-06-30 08:37:00
    First, thanks to Tim and to everyone else who has responded to my
inquiry.  Unlike some of the people on the list, I am *not* a Un*x
heavy.  Sometimes people more or less get dumped onto a system without
instruction and not even always a good idea where to start looking (or
even to find the FM if they knew what FM to RT. :) )

On Sun, 29 Jun 1997, Tim wrote (excerpted):

There are many ways to skin a cat.  Here's another way.

      FROM=`formail -rtx'To:'`
      #
      # The above grabs the "Reply-To:" if present over the "From:".
      # If you really want the "From:" address, then:

    I definitely want the From:, not Reply-To:, X-Sender:, or whatever.

      # FROM=`formail -zxc'From:'`
      #
      # grep = GNU grep v2.0
      #
      :0
      * FROM ?? ? grep -i -f $USERLIST
      { ACTION TO TAKE FOR AN ELIGIBLE SENDER }

    Why would grep be better than egrep here?   (And I can't find a
switch which will tell me whether it is a GNU or not.)

      WHOFROM=`formail -rtx'To:' | sed "s/.*<//;s/>.*//"`

    Whould this handle the case you mention below?
    >   user(_at_)domain (Foo Bar)

But why not just make the userlist file a name of "email addresses proper"
only?  That way, no matter it would make no difference whether the "From:"
line was

    As I mentioned in my original post, the form of the userlist file is

user1(_at_)domain1, user2(_at_)domain2, user3(_at_)domain3, etc.

strung out in a single record.  I may be displaying my ignorance here. 
If all tests pass, eventually $USERLIST is going to get fed into the
Bcc: field of an outgoing mail via formail, one of the fields of which
being

        -I "Bcc:" `cat $USERLIST`

If this will even work.  One respondent suggested that I make the user
file one address per line.  Unfortunately I do not know whether that
will work with sendmail as a Bcc: (i.e., with no comma after each
address and with newlines after each).  I do not have addresses
available to me for trying it out.

and you could run into problems with the above WHOFROM if someone formatted
their email address like this:

      user(_at_)domain (Foo Bar)

    Thank you.  I had not thought of that.  It all comes down to this:
1) I need to get the user(_at_)domain out of From:, stripped clean of the
nonessentials;  2) I need to determine whether user(_at_)domain is within 
a list of permissible addresses;  3) If it is, I need to generate a
mail with all members of the permissible list Bcc'ed; 4) It would be
very nice if I only had to maintain one list (i.e., both for
permissibility lookup and for feeding into Bcc:.)

    (BTW, this whole recipe is still fluid, which is why I have not
taken up space posting it here.)

Paul                             <pobart(_at_)access(_dot_)digex(_dot_)net>
----------------------------------------------------------
Paul O. Bartlett, P.O. Box 857, Vienna, VA 22183-0857, USA
Finger, keyserver, or WWW for PGP 2.6.2 public key
Home Page:  http://www.access.digex.net/~pobart