[thelist] testing for email address in perl

Adrian Fischer adrian at aussiebidder.com
Mon Jan 14 00:26:03 CST 2002


Hi Folks,

I wasnt actualy after a validation of email address's.  I was after how to
extract an email address from within a file.

What Anthony has is probably what Im after.  I want to be able to go through
my mail while its still on the server, find bounced emails and delete
information from a mysql db based on the email address.

I think validating the actual address may be easy compared to that.

Regards

Adrian Fischer

-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Paul Cowan
Sent: Monday, 14 January 2002 4:15 PM
To: 'thelist at lists.evolt.org'
Subject: RE: [thelist] testing for email address in perl


Kristy Frey wrote:

> I just had it pointed out to me in another thread that
> foo at foo.info is a valid email address
> format
>
> So perhaps, with .xxxx addresses, we need to change it to:
>
> m/(\w[-.\w]+\@[-.\w]+\.\w{2,4})\W/

Well, yeah... until .museum comes along (soon!).

May as well summarise this in a:

<tip type="Email Validation" author="Paul Cowan">
Don't overvalidate email addresses. Assuming that the
last part of an email address is 3 characters only (.com,
.net, .org) is a sure way to annoy your international
customers (.au, .br, .za...). But just because all the
current domains are 2-3 characters [1] doesn't mean that all
future ones will be: in fact, .info is already (partially)
live -- and .aero and .coop are on the way... as is the
rather enormous .museum. Perhaps you're better off just
checking the pattern, and not stressing over the length.

What's more, email addresses don't have to be alphabetic.
paul at 10.1.1.1 is a valid email address [2] -- you don't just
have to use domain names.

Oh, and so is paul at 167837953, while we're at it [3].

Anyway, if you're really determined to make it check for
a valid email, it's trivial for a user to enter
kljsdfgklsiweu at fdssdfsdf.com...

My advice: don't worry too much. Check for an @, that
will generally do.

[1] actually, they're not all 3 characters: .arpa has been
valid for yonks.

[2] well, one on a non-routable IP -- but you get the idea.

[3] See http://www.pc-help.org/obscure.htm to see why.
</tip>

--
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt !





More information about the thelist mailing list