As in, on the To: line or in the body?

        There are many email like addresses in the header, so you'd need
to pick the lines you want checked.  It's pretty easy to make a regex that
would pick out email addresses.  Also depends on if you want the form with
<> brackets around it and include a full name.  That's a bit more tricky,
but if you're only looking on the from, to, and cc lines, then they are
all comma delimited.  The body, obviously, is not.

        I assume you're either making an automatic addressbook based on
mail you've sent or received.  If that's the case, then the from, to, and
cc lines are all that really matter.

        I'm not in the mood to go through that regex that was included,
but a quick test didn't give me the results I was looking for.  You can
make a very crude script like so:

get_email_addresses_from_stream.sh:
 #!bash
 tr '<>(),:' '\n\n\n\n\n\n' | tr ' ' '\n' | grep .@.*\..*[A-z]\$ | sort -u
EOF

        That should produce a list of email addresses (or things that match the
grep) from whatever is piped to it.  So if you fiddle procmail you can
make it pipe mails coming in and dump the to a file.

        If you want it to be more useful, you shouldn't grep the headers
except for the to, from, and cc lines.  Easy enough to do with a grep at
the beginning of the line.  Also, the email address grep could easily be
improved or, I'm sure there's a better one to use.  Like the one in the
other email will probably work somehow.  But I was just imagining the most
broad sense of a valid email address would take the form of:

        [at least one character]@[at least one char].[two or three char]

        As that would satisfy all the .com, .net, .cc, .se, .tw.  You
could make it much more strict, but it all depends on what you're doing
with it.

On Wed, 18 Sep 2002, Mike O wrote:

> Okay, no wisecracks or stupid jokes on that one though
> I'm sure somebody won't be able to help themselves. 
> 
> Here's what I'm looking for. Anybody know of a program
> that'll go through all the headers in an email and
> output all of the email addresses in it to a file or
> address book?
> 
> __________________________________________________
> Do you Yahoo!?
> New DSL Internet Access from SBC & Yahoo!
> http://sbc.yahoo.com
> _______________________________________________
> Eug-lug mailing list
> [EMAIL PROTECTED]
> http://mailman.efn.org/cgi-bin/listinfo/eug-lug
> 

_______________________________________________
Eug-lug mailing list
[EMAIL PROTECTED]
http://mailman.efn.org/cgi-bin/listinfo/eug-lug

Reply via email to