127)) return false; $isEscaping = false; continue; //suppress further checks } //special treatment if the local part is quoted if ($isLocalPartQuoted) { if (($ordinal < 32) || ($ordinal > 127)) return false; if ($isClosingQuoteOccured) { //the last char was the closing quote (i.e. end of local part) -> this char must be "@" if ($ordinal == 64) { $isLocalPart = false; //it is the "@" -> the next char starts the domain part } else { return false; //another quote occured after the closing quote } } $isClosingQuoteOccured = ($ordinal == 34); //true means: found '"' which (in this case) is the closing quote for the local part continue; //suppress further checks } //normal treatment for local part characters if (!preg_match($localPartChars, $current)) { //character not allowed in local part -> it may be the "@" if ($ordinal == 64) { $isLocalPart = false; //it is the "@" -> the next char starts the domain part } else { return false; //illegal char occured } } } else { //character in domain part $domainPartCount++; if (($ordinal < 32) || ($ordinal > 127)) return false; if ($ordinal == 46) { //"." occured - starting next label $labelLength = 0; } else { //next character in this label $labelLength++; if ($labelLength == 64) { //a label may not be longer than 63 characters return false; } } } } //end of character loop -> no errors occured -> check the calculated values return ($isLocalPartQuoted) ? ($localPartCount >= 4) //must be at least the quotes, one character, and the '@', e.g. '"a"@' : ($localPartCount >= 2) //must be at least one character and the '@', e.g. 'a@' && ($domainPartCount >= 1) //must be at least one character && ($localPartCount <= 64) //recommendation of RFC 2822 && ($domainPartCount <= 255) //recommendation of RFC 2822 ; } ?>