procmail
[Top] [All Lists]

Re: Formail Q: Can I get both user name and email?

1998-03-27 23:54:36
On Fri, 27 Mar 1998, Webmarquee Newslists wrote:

      FROM=`formail -rt -x To:`
      
      How would I get the user name in one var and the email in another?

This is equivalent to the one above, just shorter and does away with
leading whitespace:
        FROM=`formail -zrtxto`

I presume the "user name" you want is the personal name. This is a little
harder to get, since it may be to the left or the right of the address,
and may or may not have quotes or parans aound it. This extracts the
"From:" line using formail, then strips the address from it using sed. If
no name is used, it should come up empty.

        NAME=`formail -zx'from:'\
        |sed -e 's/[ <]*[^ ]*(_at_)[^ ]*[ >]*//g' -e 's/[()"]//g'`

Is there some message ID I should consider as well? 

If you want to save the msgid to a var:

        MSGID=`formail -zx'Message-ID:'`

David Hunt