PHP: email validation form
- Started
- Last post
- 12 Responses
- UndoUndo0
I agree with ldww, checking mail exchange records isnt that robust just make sure they validate the email with an activation code,
I could submit yr email address and it will validate with MX record but its not mine, so activation through email is more reliable IMO
- UndoUndo0
this will validate emails in the correct format
ie. use@domani.extension
will validate
but
john&john@somedomain.$uperwont
but will not check that the domain has a valid mail exchange record. sorry for the confusion
- ldww0
as a sidenote, i have never actually checked the hostname. i think most people are content with making sure the email looks right.
if you are very concerned about a vlid email address just require email confirmation by sending them an email with some kind of keycode.
- kinetic0
sorry mate...should have read your post
im always doing that ;)
- fifty500
oh feck. that was the original problem. what I had was validating most emails but my buddy tried it with his and it came back as invalid!
- UndoUndo0
curtis what I sent to you will check that the email address 'looks right' not that it has valid mail exchange records, you might want to add that from yr other function
- fifty500
Ed Zachary what ldww said
- ldww0
kinetic, that is just a regex. he wants to check the hostname to see if it is a valid host rather then whatevernameusertypes.com. reg ex will just see if it looks right, not valid.
- kinetic0
this function has always served me well:
function check_email($email) {
if(eregi("^[a-z0-9\._-]+@+[a-z0... $email)) {
return TRUE;
} else {
return FALSE;
}
}
- fifty500
thanks guys i'll give them both a shot and see what happens.
- ldww0
i see you are using getmxrr. why not try the example in the comments? they do it a bit differently then you.
- UndoUndo0
you got mail!
- fifty50
I've got this PHP email validation form on my site:
http://curtis.nexteradesign.com/…
That's basically the meat of it. For some reason, though, some valid email addresses get returned as being invalid. For example or come back as being invalid, even though the domains are in fact valid. Help?