function hook_valid_email_address_alter
Alter core e-mail validation.
This hook is called immediately after core e-mail validation takes place and gives other modules a chance to override it. This is useful in cases where you want to have stricter or looser validation standards than that provided by Drupal core.
Parameters
$valid: Boolean value referencing the validation result.
$mail: E-mail address being validated.
See also
Related topics
1 function implements hook_valid_email_address_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- user_email_validation_test_valid_email_address_alter in modules/
user/ tests/ user_email_validation_test.module - Implements hook_valid_email_address_alter().
1 invocation of hook_valid_email_address_alter()
- valid_email_address in includes/
common.inc - Verifies the syntax of the given e-mail address.
File
-
modules/
system/ system.api.php, line 4836
Code
function hook_valid_email_address_alter(&$valid, $mail) {
if (preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\\._-]+)+\$/", $mail)) {
list($username, $domain) = explode('@', $mail);
// Check DNS records.
if (checkdnsrr($domain, 'MX')) {
$valid = TRUE;
}
}
$valid = FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.