M.O.S. Studios Posted July 13, 2010 Share Posted July 13, 2010 working on a function that makes sure an entered email is valid. I'm having some problems, i think it might be with the preg_match() or with the regex, if i take that out of the function it runs fine but doesn't detect format. function email_vari($email){ list($username,$domain)=split('@',$email); if((!preg_match("/(^[a-z.-_0-9]*)/i", $username)) && (!preg_match("/(^[a-z0-9]*)/i", $domain))){ list($username,$domain)=split('@',$email); if(!getmxrr ($domain,$mxhosts)){ $return = FALSE; }else{ $return = TRUE; } }else{ $return = FALSE; } if($return === FALSE){return VALIDEMAIL;} } any ideas thanks in advance Link to comment https://forums.phpfreaks.com/topic/207658-email-detection/ Share on other sites More sharing options...
ocpaul20 Posted July 14, 2010 Share Posted July 14, 2010 Plenty of good examples of this out there on the internet. Why re-invent the wheel? Link to comment https://forums.phpfreaks.com/topic/207658-email-detection/#findComment-1085667 Share on other sites More sharing options...
M.O.S. Studios Posted July 15, 2010 Author Share Posted July 15, 2010 because its about time we replace the wheel with hover jets. function email_vari($email){ if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)){ $return = FALSE; }else{ list($Username, $Domain) = split("@",$email); if(@getmxrr($Domain, $MXHost)){ $return = TRUE; }else{ if(@fsockopen($Domain, 25, $errno, $errstr, 30)){ $return = TRUE; }else{ $return = FALSE; } } } if($return === FALSE){return VALIDEMAIL;} } Link to comment https://forums.phpfreaks.com/topic/207658-email-detection/#findComment-1086491 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.