Improved logging of email validation function

This commit is contained in:
2015-04-21 10:55:56 +10:00
parent 2922ef0ecb
commit 515c2e67d7
2 changed files with 12 additions and 7 deletions

View File

@@ -6,18 +6,23 @@
*/
function _valid_email_address($email) {
//firstly use the built-in function to validate the format
if (! valid_email_address($email))
if (! valid_email_address($email)) {
watchdog('booking', "Drupal validation of email address '!email' returns false.", array('!email' => $email));
return false;
}
//now check the domain exists
if (preg_match('/^(.*?)\@(.*)/', $email, $matches)) {
//watchdog('booking', 'Email address checking: @info', array('@info' => var_export($matches, TRUE)));
if (! checkdnsrr($matches[2], "MX"))
return 0;
return 1;
if (! checkdnsrr($matches[2], "MX")) {
watchdog('booking', "No valid MX record found for email address '!email' with domain name !domain", array('!email' => $email, '!domain' => $matches[2]));
return false;
}
return true;
}
watchdog('booking', "Regular expression failed to detect domain portion of email address '!email'", array('!email' => $email));
//watchdog('booking', 'Email address checking doesnt match');
return 0;
return false;
}
/**