The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

I read that code. And ok, we may change the syntax check.
And I have 2 questions.

1.: It seems to me, that it really identify the user. Not just the domain. Am I wrong? I didn't see anything like this before.
Is it really possible? That would be the most precise validation.

2.: And the second question is:
Can anybody give me an url or something( how to find these with google ) where I can read about these "socket messages". I'm not "specialized" about sockets. And I need a good reference about making socket connections with mail servers. What commands can I send, what can I get.

Thanks for the link, and thanks your help in advance! I need this stuff, but I have no clue where to get info about that.

The most important part of this post is the bottom of it. But first things first!

Alright, that eregi at the beginning is kind of weak, however, that part is super-easy to change.

First, the slower eregi, can be switched out for the faster preg:

Code:

(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*
@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$Email))
// to:
(!preg_match('#^[_a-z0-9-]+(?:\.[_a-z0-9-]+)*
@[a-z0-9-]+(?:\.[a-z0-9-]+)*(?:\.[a-z]{2,3})$#i',$Email))
note: I hate it when long code forces the entire thread to get too wide,
so I put in a line break before each "@". Cut and pasters should remember
to remove that line break. :-)

Hope I did that correctly, didn't look like much needed changing.
Second, the {2,3} represents {minimum,maximum} number of characters in the top level domain and you can change either of those to whatever you want. For a minimum of 2, max of 4 use {2,4}. Leave the second number out (keep the comma!) and any length will be allowed. {2,}

On an probably unnecessary efficiency tip, the splitting section of the code could have been replaced by a match in the regex, probably would have been faster since the regex had to be done anyhow. Another reason to use preg.

Anyway, that tip is probably unnecessary because it is going to be the socket connection to the other server that will slow things down to a factor far greater than the time that regex and split would take.

I checked some earthlink.net addresses and those worked alright, so it at least works some of the time.

Oh, just tried aol.com and I'm getting false negatives (in other words, correct addresses being diagnosed as invalid), that's a big problem. Check it out, it's probably just one or two server types or something that have to be excluded from the address check.

Last edited by samsm; Nov 16, 2003 at 00:58.
Reason: ++clarity

Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?