How to determine if a string is an EMail account

  • Thread starter Thread starter ad
  • Start date Start date
How to determine if a string is an EMail account?

Do you mean how to verify that a string is in a valid email address format,
or that the email address actually exists...?

The former is very easy - that latter is very difficult...
 
You mean the format? If yes, you can use regular expressions. Check out
www.regexlib.com for various expressions to test email addresses.

Hi,
As title,

How to determine if a string is an EMail account?
 
Mark said:
Do you mean how to verify that a string is in a valid email address format,
or that the email address actually exists...?

The former is very easy - that latter is very difficult...

Well, not really. Send an email to the address and see if you get a
bounced message back. Yes, I know, its not exactly what people had in
mind.

Still, format is fairly easy. (e-mail address removed), where the
somethings all have letters, numbers, underscores, or dashes.


matt
 
Still, format is fairly easy. (e-mail address removed), where the
somethings all have letters, numbers, underscores, or dashes.

The following are correct email addresses that the above will fail to
validate:

(e-mail address removed)
(e-mail address removed)
(e-mail address removed)
user@localhost

There must be a thousand incorrect email validator implementations for
each correct one. Writing a correct email format validator is far more
difficult than most people think. There is a reason that the regex to
parse rfc822 is as large as it is.
 
Marcus said:
The following are correct email addresses that the above will fail to
validate:

(e-mail address removed)
(e-mail address removed)
(e-mail address removed)
user@localhost

There must be a thousand incorrect email validator implementations for
each correct one. Writing a correct email format validator is far more
difficult than most people think. There is a reason that the regex to
parse rfc822 is as large as it is.

The question was really just recognizing one. If all of the characters
are valid, and it only has one @ sign (you are correct, though, I left
off the period) its a potentially valid email address. I'm assuming
that he wanted to format them differently. Checking to see if a given
address really exists is a whole different matter, as most have pointed
out. You could do a quick check to see if the domain was valid via DNS
lookup, and then validate the user-name according to the rules, I
suppose.

Matt
 
Still, format is fairly easy. (e-mail address removed), where the
somethings all have letters, numbers, underscores, or dashes.

Er, I think there's just a tad more to it than that...
 
Back
Top