| 429 | | $regex = "/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i"; |
| 430 | | |
| 431 | | if (preg_match_all($regex, $email, $_matches)) { |
| 432 | | // If the hostname is black listed, reject the email address |
| 433 | | $full_hostname = $_matches[2][0] . "." . $_matches[3][0]; |
| 434 | | |
| 435 | | if (!in_array(strtolower($full_hostname), self :: $_hosts_black_list)) { |
| 436 | | $_retVal = true; |
| | 432 | // $regex = "/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i"; |
| | 433 | // The full regex is |
| | 434 | // /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i |
| | 435 | // We will check it in two parts: domain and local |
| | 436 | |
| | 437 | $atIndex = strrpos($email, "@"); |
| | 438 | if ($atIndex !== false) |
| | 439 | { |
| | 440 | $domain = substr($email, $atIndex+1); |
| | 441 | $local = substr($email, 0, $atIndex); |
| | 442 | |
| | 443 | // Verify local part |
| | 444 | if (preg_match("/^[a-z0-9!#$%&'*+\\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\\/=?^_`{|}~-]+)*$/i",$local) && |
| | 445 | preg_match("/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i",$domain) ) |
| | 446 | { |
| | 447 | |
| | 448 | if (!in_array(strtolower($domain), self :: $_hosts_black_list)) { |
| | 449 | if (checkdnsrr($domain,"MX") || checkdnsrr($domain,"A")) { |
| | 450 | $_retVal = true; |
| | 451 | } |
| | 452 | } |