You are here

function user_validate_mail in Drupal 7

Same name and namespace in other branches
  1. 4 modules/user.module \user_validate_mail()
  2. 5 modules/user/user.module \user_validate_mail()
  3. 6 modules/user/user.module \user_validate_mail()

Validates a user's email address.

Checks that a user's email address exists and follows all standard validation rules. Returns error messages when the address is invalid.

Parameters

$mail: A user's email address.

Return value

If the address is invalid, a human-readable error message is returned. If the address is valid, nothing is returned.

4 calls to user_validate_mail()
install_configure_form_validate in includes/install.core.inc
Form validation handler for install_configure_form().
system_site_information_settings_validate in modules/system/system.admin.inc
Validates the submitted site-information form.
UserValidationTestCase::testMailAddresses in modules/user/user.test
user_account_form_validate in modules/user/user.module
Form validation handler for user_account_form().

File

modules/user/user.module, line 673
Enables the user registration and login system.

Code

function user_validate_mail($mail) {
  if (!$mail) {
    return t('You must enter an e-mail address.');
  }
  if (!valid_email_address($mail)) {
    return t('The e-mail address %mail is not valid.', array(
      '%mail' => $mail,
    ));
  }
}