Forum Moderators: coopster
info at google dot com dot in
info dot me at google dot com
info dot me dot you at google dot com
are all valid email.
info at google dot com dot ins is invalid
I need improve
if (!preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email))
die("Error in email");
function isValidInetAddress($data, $strict = false)
{
$regex = $strict?
'/^([.0-9a-z_-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i' :
'/^([*+!.&#$¦\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i'
;
if (preg_match($regex, trim($data), $matches)) {
return array($matches[1], $matches[2]);
} else {
return false;
}
}
Email format can be:
<!--email format--><!--
[combination of letters, numerals, one minus at a time, one underscore at a time] dot
[combination of letters, numerals, one minus at a time, one underscore at a time] dot
.........above pattern.........
@
[combination of characters, numerals, one minus at a time]
dot
[ two or three letters ]
dot
[ two letters, optional ]
--><!-- neglected info[yahoo dot com] or info[66.94.234.13] though valid -->
And it's good, if we write correct 'regex' to it to be used in preg_match()
this one just checks for valid format
preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/', $email2
function valid_email_address($email)
if (strlen($email) < 9) return false; // need at least 9 characters (e.g. x@aaa.net)
$pos = strpos($email,'@');
if ($pos === false or $pos === 0) return false; // no @ symbol
list($user_name, $mail_domain) = split("@",$email); // Split email address into username and domain name
if (checkdnsrr($mail_domain, "MX")) return true;
return false; // Invalid email address
}