8.5.x user.module user_load_by_mail($mail)
8.0.x user.module user_load_by_mail($mail)
8.1.x user.module user_load_by_mail($mail)
8.2.x user.module user_load_by_mail($mail)
8.3.x user.module user_load_by_mail($mail)
8.4.x user.module user_load_by_mail($mail)
8.6.x user.module user_load_by_mail($mail)
7.x user.module user_load_by_mail($mail)

Fetch a user object by email address.


$mail: String with the account's e-mail address.

Return value

A fully-loaded $user object upon successful user load or FALSE if user cannot be loaded.

See also


1 call to user_load_by_mail()
system_send_email_action in modules/system/system.module
Sends an e-mail message.


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


function user_load_by_mail($mail) {
  $users = user_load_multiple(array(), array(
    'mail' => $mail,
  return reset($users);


sokrplare’s picture

Looking through backported code and noticed this succinct D6 equivalent:
$user = user_load(array('mail'=> 'dries@example.com'));

andeersg’s picture

If you use this to check if a user exists, beware that an empty string will return the anonymous user.

Rob230’s picture

What a shame that this does not do a case insensitive check. It makes the function basically useless. If anyone wants to really check whether an email address is registered or fetch that user, they must write their own function similar to what user_account_form_validate() does in user.module (it does a db_select() with db_like(), rather than using this function).

In an ideal world, this function would do that, and user_account_form_validate() would call it.

Rob230’s picture

Disregard my comment. I tested this function and it appears to be case insensitive, although this may be dependent on the collation of the database (MySQL by default should do a case insensitive search with a basic WHERE mail = 'something@example.com'.

nerdcore’s picture

Calling user_load_by_mail(NULL) returns the Anonymous user, not FALSE as I had expected.

You might want to watch for this.