/ Published in: PHP
Expand |
Embed | Plain Text
function checkEmail($email) { // Create the syntactical validation regular expression $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"; // Presume that the email is invalid $valid = 0; // Validate the syntax { // Validate the domain $valid = 1; } else { $valid = 0; } return $valid; }
Comments
Subscribe to comments
You need to login to post a comment.

Nice. getmxrr - would this slow down the script if I use a non-existing domain?
@Nils, No. The function just checks characters within the string. It allows only lowercase letters (a through z), numbers (0 through 9), fullstops before checking if an @ symbol is somewhere in the middle and if a fullstop is somewhere after the @ symbol, as well as checking if there are no more 4, no less than 2 characters after that fullstop.
@kapooht...Sorry but the getmxrr function should not be used for address verification.
"This function should not be used for the purposes of address verification. Only the mailexchangers found in DNS are returned, however, according to ยป RFC 2821 when no mail exchangers are listed, hostname itself should be used as the only mail exchanger with a priority of 0."
in http://php.net/manual/en/function.getmxrr.php