Hans Lommeuld udtrykte præcist:
function ValidEmail($email) {
$isValid = true;
if (($atIndex = strrpos($email, "@")) === false) {
$isValid = false;
}
else {
$domain = substr($email, $atIndex+1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ( ($localLen < 1 || $localLen > 64) || // local part length
exceeded
($domainLen < 1 || $domainLen > 255) || // domain part length
exceeded
($local[0] == '.' || $local[$localLen-1] == '.') || // local part
starts or ends with '.'
(preg_match('/\\.\\./', $local)) || // local part has two
consecutive dots
(!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) || // character
not valid in domain part
(preg_match('/\\.\\./', $domain)) || // domain part has two
consecutive dots
( (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
str_replace("\\\\","",$local))) && // character not valid in local part
(!preg_match('/^"(\\\\"|[^"])+"$/',
str_replace("\\\\","",$local))) ) || // unless local part is quoted
(!(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"))) //
domain not found in DNS
) {
$isValid = false;
}
}
return $isValid;
}
Birger
--
http://varmeretter.dk - billig, sund og hurtig mad
http://skippersevent.dk