Crude Email Adddress CHecking

B

Bob

OK, admitting up front that I know it's impossible to actually check
email addresses for validity due to the possible valid address
formats...

I'm looking for a routine/chunk of code that will check email
addresses for compliance with fairly standard formats i.e. it
needs to be (e-mail address removed) format, contain no spaces, etc.

Anyone have a chunk or a pointer?

Thanks,

Bob (barely a perl programmer :)
 
S

Stephen Hildrey

Bob said:
OK, admitting up front that I know it's impossible to actually check
email addresses for validity due to the possible valid address
formats...

I'm looking for a routine/chunk of code that will check email
addresses for compliance with fairly standard formats i.e. it
needs to be (e-mail address removed) format, contain no spaces, etc.

perldoc -q "valid mail"

Steve
 
P

Paul Lalli

Bob said:
Note: The author of this message requested that it not be archived. This
message will be removed from Groups in 6 days (Sep 15, 8:08 am).

That's rude. Questions and answers should be available to everyone
searching this group later. Please don't do that again.
OK, admitting up front that I know it's impossible to actually check
email addresses for validity due to the possible valid address
formats...

I'm looking for a routine/chunk of code that will check email
addresses for compliance with fairly standard formats i.e. it
needs to be (e-mail address removed) format, contain no spaces, etc.

It's time to ask yourself why you want to do this. You already *know*
the inherent problems with "validating" email addresses. So what are
you trying to accomplish? Do you really want to forbid those people
with "non-standard" formats from using whatever service you're
providing?

Since you've stated that you want to match "fairly standard" formats,
you're going to need to state exactly what formats you want to match.

No spaces: $email =~ /^\S+$/
something-at-something-dot-something: /^.+\@.+\..+$/

For more information on why this is more complex than you're imagining,
and why you probably shouldn't be doing it anyway:
perldoc -q address
OR
http://perldoc.perl.org/perlfaq9.html#How-do-I-check-a-valid-mail-address?

Paul Lalli
 
C

ced

Paul said:
That's rude. Questions and answers should be available to everyone
searching this group later. Please don't do that again.


It's time to ask yourself why you want to do this. You already *know*
the inherent problems with "validating" email addresses. So what are
you trying to accomplish? Do you really want to forbid those people
with "non-standard" formats from using whatever service you're
providing?

Since you've stated that you want to match "fairly standard" formats,
you're going to need to state exactly what formats you want to match.

No spaces: $email =~ /^\S+$/
something-at-something-dot-something: /^.+\@.+\..+$/

For more information on why this is more complex than you're imagining,
and why you probably shouldn't be doing it anyway:
perldoc -q address
OR
http://perldoc.perl.org/perlfaq9.html#How-do-I-check-a-valid-mail-address?

With all the usual caveats, Email::Valid may be an option.
(It's been around quite a while -- I'm surprised there's no
mention of it in the faq)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top