8.5.x user.module _user_mail_notify($op, $account, $langcode = NULL)
8.0.x user.module _user_mail_notify($op, $account, $langcode = NULL)
8.1.x user.module _user_mail_notify($op, $account, $langcode = NULL)
8.2.x user.module _user_mail_notify($op, $account, $langcode = NULL)
8.3.x user.module _user_mail_notify($op, $account, $langcode = NULL)
8.4.x user.module _user_mail_notify($op, $account, $langcode = NULL)
8.6.x user.module _user_mail_notify($op, $account, $langcode = NULL)
6.x user.module _user_mail_notify($op, $account, $language = NULL)
7.x user.module _user_mail_notify($op, $account, $language = NULL)

Conditionally create and send a notification email when a certain operation happens on the given user account.


$op: The operation being performed on the account. Possible values:

  • 'register_admin_created': Welcome message for user created by the admin.
  • 'register_no_approval_required': Welcome message when user self-registers.
  • 'register_pending_approval': Welcome message, user pending admin approval.
  • 'password_reset': Password recovery request.
  • 'status_activated': Account activated.
  • 'status_blocked': Account blocked.
  • 'cancel_confirm': Account cancellation request.
  • 'status_canceled': Account canceled.

$account: The user object of the account being notified. Must contain at least the fields 'uid', 'name', and 'mail'.

$language: Optional language to use for the notification, overriding account language.

Return value

The return value from drupal_mail_system()->mail(), if ends up being called.

See also



2 calls to _user_mail_notify()
user_pass_submit in modules/user/user.pages.inc
Form submission handler for user_pass().
user_save in modules/user/user.module
Save changes to a user account or add a new user.


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


function _user_mail_notify($op, $account, $language = NULL) {

  // By default, we always notify except for canceled and blocked.
  $default_notify = $op != 'status_canceled' && $op != 'status_blocked';
  $notify = variable_get('user_mail_' . $op . '_notify', $default_notify);
  if ($notify) {
    $params['account'] = $account;
    $language = $language ? $language : user_preferred_language($account);
    $mail = drupal_mail('user', $op, $account->mail, $language, $params);
    if ($op == 'register_pending_approval') {

      // If a user registered requiring admin approval, notify the admin, too.
      // We use the site default language for this.
      drupal_mail('user', 'register_pending_approval_admin', variable_get('site_mail', ini_get('sendmail_from')), language_default(), $params);
  return empty($mail) ? NULL : $mail['result'];


finn.lewis’s picture

For the record, using $op = 'register_no_approval_required' results in default email with the 'now verify your account by clicking this link' content, allowing the user to confirm their email address.

Pryrios’s picture

Thank you for pointing it out. I will file an issue here as this is not clear on the docs.

I was looking for exactly this and was starting to get mad at it >_<.

swirt’s picture

To get rid of that misleading direction for clicking the link to confirm their email, you can go to here
and just edit the message that gets sent out for "Welcome (no approval required)"

rajesh.vishwakarma’s picture

I am sending activation link to all user those accounts are not activated. It working fine if account is active but not worked if account "last login" status is NEVER.

$uid = 258;
$account = user_load($uid);
$op = 'register_no_approval_required';
$status = _user_mail_notify($op, $account);

agerson’s picture

It looks like that is by design:

// By default, we always notify except for canceled and blocked.
$default_notify = ($op != 'status_canceled' && $op != 'status_blocked');