Xurion Posted October 10, 2006 Share Posted October 10, 2006 If I have an email address field that the user fills in, what is the best way to detect if that email is real?Do I simply detect if there is an @ symbol there? Or is there another way to detect if it is genuine?Thx in advance :) Link to comment https://forums.phpfreaks.com/topic/23514-detecting-if-an-email-is-genuine/ Share on other sites More sharing options...
hostfreak Posted October 10, 2006 Share Posted October 10, 2006 Here is what I use, most of the time:[code]$email = $_POST['email'];$regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{1,})*\.([a-z]{2,}){1}$";if (!eregi($regex,$email)) { echo "Invalid Email!";}else { //do whatever}[/code] Link to comment https://forums.phpfreaks.com/topic/23514-detecting-if-an-email-is-genuine/#findComment-106693 Share on other sites More sharing options...
vbnullchar Posted October 10, 2006 Share Posted October 10, 2006 what if you want to check if the email address is really existing? Link to comment https://forums.phpfreaks.com/topic/23514-detecting-if-an-email-is-genuine/#findComment-106699 Share on other sites More sharing options...
hostfreak Posted October 10, 2006 Share Posted October 10, 2006 Do you mean something like:[code]if (empty($_POST['email'])) { echo "No email was entered";}else { //do whatever}[/code]? Link to comment https://forums.phpfreaks.com/topic/23514-detecting-if-an-email-is-genuine/#findComment-106703 Share on other sites More sharing options...
vbnullchar Posted October 10, 2006 Share Posted October 10, 2006 nope i mean how can you check if the domain entered really existex. [email protected] <- this is existing[email protected] <- can u determine if somewhere.com really exist.. Link to comment https://forums.phpfreaks.com/topic/23514-detecting-if-an-email-is-genuine/#findComment-106705 Share on other sites More sharing options...
HuggieBear Posted October 10, 2006 Share Posted October 10, 2006 Yes, you can attempt to resolve the name first by performing an MX Lookup.For further details try googling [url=http://www.google.co.uk/search?hl=en&q=%22Validate+email%22+%2Blookup&btnG=Search&meta=]"Validate Email" +Lookup[/url]RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/23514-detecting-if-an-email-is-genuine/#findComment-106707 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.