Page 1 of 3
validate an email adress
Posted: Tue Jul 12, 2005 8:19 am
by adixtopix
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.
Posted: Tue Jul 12, 2005 8:24 am
by protokol
The following URL will help you to define your regex:
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
Posted: Tue Jul 12, 2005 9:54 am
by neophyte
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
Posted: Tue Jul 12, 2005 12:21 pm
by Roja
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
That nice simple regex is not RFC compliant, and will fail on *correct* email addresses.
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.
Posted: Tue Jul 12, 2005 12:54 pm
by timvw
Posted: Tue Jul 12, 2005 6:25 pm
by bokehman
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.
Posted: Tue Jul 12, 2005 6:34 pm
by Burrito
d11 pointed me to this thread and omg...holy mother of regex and all things regexableish
could someone please give me a line-by-line explanation of what that does? I don't get it

Posted: Tue Jul 12, 2005 6:53 pm
by timvw
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.
It doesn't work for me...
Enter an email:
timvw@users.sourceforge.net
Warning: The email entered does not appear to be valid.
Posted: Tue Jul 12, 2005 7:21 pm
by bokehman
timvw wrote:It doesn't work for me...
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.
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.
Posted: Tue Jul 12, 2005 7:24 pm
by neophyte
Roja wrote:That nice simple regex is not RFC compliant, and will fail on *correct* email addresses.
And again:
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.
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.
Posted: Tue Jul 12, 2005 7:28 pm
by bokehman
Burrito wrote:could someone please give me a line-by-line explanation of what that does? I don't get it

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.
Posted: Tue Jul 12, 2005 7:30 pm
by bokehman
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.
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.
Posted: Tue Jul 12, 2005 7:34 pm
by Burrito
bokehman wrote:Burrito wrote:could someone please give me a line-by-line explanation of what that does? I don't get it

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.
actually I meant the mother of all regex's (/me pulls tongue out of his cheek)...I didn't look at your thingy.
Posted: Tue Jul 12, 2005 9:43 pm
by Roja
neophyte wrote:
I'm just waiting for Roja to post the mother of all REGEX for email validation that works for PHP.
Sorry for the delay. Its up!
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.
Posted: Tue Jul 12, 2005 9:49 pm
by Roja
bokehman wrote: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.
So which method are you using to ask it that? VRFY?