validate an email adress
Moderator: General Moderators
validate an email adress
okay, i need a way to validate an email adress, a function
not the ones from the php.net
they do not work as i wish
one of them validates an email even if it looks like a@a.
not the ones from the php.net
they do not work as i wish
one of them validates an email even if it looks like a@a.
- protokol
- Forum Contributor
- Posts: 353
- Joined: Fri Jun 21, 2002 7:00 pm
- Location: Cleveland, OH
- Contact:
The following URL will help you to define your regex:
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
That's got to be the longest regex I've ever seen! How bout the nice simple regex in the snippets section:
viewtopic.php?t=34883
viewtopic.php?t=34883
That nice simple regex is not RFC compliant, and will fail on *correct* email addresses.neophyte wrote:That's got to be the longest regex I've ever seen! How bout the nice simple regex in the snippets section:
viewtopic.php?t=34883
Don't blame the regex. Blame the RFC for allowing truly insane and outlandish email addresses. How about the ever-so-simple question of how LONG an email address can be?
Would you believe it can be *over* 255 characters long?
Yeah. The RFC is insane. The correct regex simply codifies the insanity from the RFC.
Don't take shortcuts.. while its a long regex, its actually amazingly fast. The function we use (I promise I'll post a link to it as soon as its up) uses a php variant of the official regex from the ultimate regex book. Despite its size, it executes in fractions of a second.
I'd rather be accurate and longer, than inaccurate and shorter.
I have written a script that actually connects to the remote mailserver to see if it will accept mail for an address all done in real time while the client is still filling in the form. Here's a demonstration.
It doesn't work for me...bokehman wrote:I have written a script that actually connects to the remote mailserver to see if it will accept mail for an address all done in real time while the client is still filling in the form. Here's a demonstration.
Enter an email: timvw@users.sourceforge.net
Warning: The email entered does not appear to be valid.
Well, well, well... I don't believe it. Sourceforge did a check to see if I have a postmaster account set up at my mail server and rejected the mail because I didn't.timvw wrote:It doesn't work for me...
550-Postmaster verification failed while checking <mailer-daemon@myhomewebserver.co.uk>
Anyway I have side stepped it now by using the 'mail to' as the 'mail from' address. Anyway try it now.
Thanks for finding that bug.
And again:Roja wrote:That nice simple regex is not RFC compliant, and will fail on *correct* email addresses.
I'm just waiting for Roja to post the mother of all REGEX for email validation that works for PHP. Until he does, I'm sticking with the simple stuff that works on *most* email address. Although, I hate it when people try to get fancy and throw dots into the mix.Roja wrote:Don't take shortcuts.. while its a long regex, its actually amazingly fast. The function we use (I promise I'll post a link to it as soon as its up) uses a php variant of the official regex from the ultimate regex book. Despite its size, it executes in fractions of a second.
Well the XML Http request object can send requests to and from the server without a page reload and when this is combined with javascript returned information can be dynamically intergrated into the page. The back end of this is just a PHP script using fsockopen() to interogate the remote mail server.Burrito wrote:could someone please give me a line-by-line explanation of what that does? I don't get it
This is nothing to do with REGEX. It is a real time connection with the remote mail server to see if it will accept mail for an address it has authority for.neophyte wrote:post the mother of all REGEX for email validation that works for PHP. Until he does, I'm sticking with the simple stuff that works on *most* email address. Although, I hate it when people try to get fancy and throw dots into the mix.
actually I meant the mother of all regex's (/me pulls tongue out of his cheek)...I didn't look at your thingy.bokehman wrote:Well the XML Http request object can send requests to and from the server without a page reload and when this is combined with javascript returned information can be dynamically intergrated into the page. The back end of this is just a PHP script using fsockopen() to interogate the remote mail server.Burrito wrote:could someone please give me a line-by-line explanation of what that does? I don't get it
Sorry for the delay. Its up!neophyte wrote: I'm just waiting for Roja to post the mother of all REGEX for email validation that works for PHP.
http://svn.gna.org/viewcvs/blacknova/tr ... iew=markup
Very simple. Pass it an RFC compliant email, and it returns true. Pass it bogus info, and it returns false.
Patches, comments, and rude limericks all welcome.