/**
  * Check email address validity
  * @param   strEmailAddress     Email address to be checked
  * @return  True if email is valid, false if not
  */
 public static function check_email_address($strEmailAddress)
 {
     // If magic quotes is "on", email addresses with quote marks will
     // fail validation because of added escape characters. Uncommenting
     // the next three lines will allow for this issue.
     //if (get_magic_quotes_gpc()) {
     //    $strEmailAddress = stripslashes($strEmailAddress);
     //}
     // Control characters are not allowed
     if (preg_match('/[\\x00-\\x1F\\x7F-\\xFF]/', $strEmailAddress)) {
         return false;
     }
     // Split it into sections using last instance of "@"
     $intAtSymbol = strrpos($strEmailAddress, '@');
     if ($intAtSymbol === false) {
         // No "@" symbol in email.
         return false;
     }
     $arrEmailAddress[0] = substr($strEmailAddress, 0, $intAtSymbol);
     $arrEmailAddress[1] = substr($strEmailAddress, $intAtSymbol + 1);
     // Count the "@" symbols. Only one is allowed, except where
     // contained in quote marks in the local part. Quickest way to
     // check this is to remove anything in quotes.
     $arrTempAddress[0] = preg_replace('/"[^"]+"/', '', $arrEmailAddress[0]);
     $arrTempAddress[1] = $arrEmailAddress[1];
     $strTempAddress = $arrTempAddress[0] . $arrTempAddress[1];
     // Then check - should be no "@" symbols.
     if (strrpos($strTempAddress, '@') !== false) {
         // "@" symbol found
         return false;
     }
     // Check local portion
     if (!EmailAddressValidatorUtil::check_local_portion($arrEmailAddress[0])) {
         return false;
     }
     // Check domain portion
     if (!EmailAddressValidatorUtil::check_domain_portion($arrEmailAddress[1])) {
         return false;
     }
     // If we're still here, all checks above passed. Email is valid.
     return true;
 }