Below you will find a small useful function on PHP that uses regular expressions to find out if a provided email address has a valid format or not.
<?PHP
function correctemail($emailtocheck) {
if (! preg_match( '/^[A-Za-z0-9!#$%&\'*+-/=?^_`{|}~]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+[A-Za-z]$/', $emailtocheck)) {
return false;
} else {
return true;
}
}
?>
The script wont check for valid domains but for RFC compliant type addresses, all in all you could combine this function with one that checks if a provided domain under an email is valid and that should do the trick.
Recent Comments