Checks if an email is formally valid, note that this doesn't mean that such email address exists. There are scripts to connect to a smtp server and test if a user exist faking to send him/her an email, but in my opinion the best way to test if an address works is sending an email there and have the user click some activation url.
/** Checks is the provided email address is formally valid
* @param string $email email address to be checked
* @return true if the email is valid, false otherwise
*/
function valid_email($email) {
$regexp="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
if ( !preg_match($regexp, $email) ) {
$_obweb->addErr("Email address is not correct\n");
return false;
}
return true;
}