19

I have made a deep research over the web and I also tried a lot of alternative solutions, but I didn't find any solution to disable the email notification for new users.

In my User Settings, I have the option "Visitors can create accounts but administrator approval is required" checked, and the option "Require e-mail verification when a visitor creates an account" not checked.

Do you have any idea?

7 Answers 7

30

If you look at the function _user_email_notify(), it checks the variable 'user_mail_' . $op . '_notify' if it should send an email or not. Assuming that you have disabled email confirmation (otherwise, disabling mail notifications would be weird ;)), the $op is 'register_no_approval_required'. So the full variable name is 'user_mail_register_no_approval_required_notify'.

There doesn't seem to be a User Interface for that variable. However, you can set it in your settings.php, adding the following line at the end of settings.php (probably inside sites/default).

$conf['user_mail_register_no_approval_required_notify'] = FALSE;

You can do the same for other mail notifications too; the other possible $op values are listed on the linked page.

4
  • Thank you so much. It is so hard to believe that there is not admin setting.
    – qasimzee
    Nov 20, 2013 at 12:58
  • Actually, I can see a use-case for preventing emails w/ user confirmation required. The system emails are pretty limited if you want to send html emails or vary the response by user role, so I can seeing wanting to take over this workflow with Rules & custom emails. Thanks @Berdir.
    – doub1ejack
    Feb 26, 2014 at 20:03
  • FYI, the 'mailcontrol' module below is this same solution rolled into a simple module. Don't overlook it.
    – doub1ejack
    Feb 26, 2014 at 21:46
  • You can also set this variable on the database. In the variable table
    – Alfonso_MA
    Aug 12, 2020 at 23:01
8

You can use the Mailcontrol module.

It allows you to turn on/off any standard Drupal mail you wish right from the UI.

Have full control over the default mails sent by Drupal 7 out of the box.

Description

This small module extends original Drupal 7 account settings page with the ability to globally turn ON/OFF all standard mails. By default Drupal 7 provides no option to globally disable the following mails:

  • Welcome (new user created by administrator)
  • Welcome (awaiting approval)
  • Welcome (no approval required)
  • Password recovery
5

In Drupal 8, the the equivalent of the code given from Berdir for the settings.php file is the following one.

$config['user.settings']['notify.register_no_approval_required'] = FALSE;
0
4

You can use this in a custom module to add the settings in a checkbox as it is done in account activation settings.

function your_module_form_user_admin_settings_alter(&$form, &$form_state) {

  // allow admin to choose if a notification mail is sent to no approval required users
  form['email_no_approval_required']['user_mail_register_no_approval_required_notify'] = array(
    '#type' => 'checkbox',
    '#title' => t('Notify user when account is created.'),
    '#default_value' => variable_get('user_mail_register_no_approval_required_notify', FALSE),
  );
}
4

In Drupal 7:

You can edit the variable table directly: name: user_mail_status_activated_notify value: i:0;

or in your template.php file:

if(variable_get('user_mail_status_activated_notify') == 1){
    variable_set('user_mail_status_activated_notify', 0);
}
1

There is a checkbox to disable at admin/user/user/create. For me, it's disabled by default.

3
  • Yes, this really is supposed to work, but, I meant, in case of anonymous registration, do not send an automatic email notify.
    – lnunesbr
    May 3, 2011 at 21:11
  • @Inunesbr What do you mean with "anonymous registration"?
    – apaderno
    May 3, 2011 at 21:18
  • @kiamlaluno the visitor who creates an account by itself in "user/register"
    – lnunesbr
    May 3, 2011 at 21:22
1

For Drupal 8 following work for me.

The following code does not send an email after registration.

/**
 * Implements hook_mail_alter().
 *
 * Don't send any mail during registration.
 */
function mymodule_mail_alter(&$message) {
  if ($message['id'] == 'user_register_no_approval_required' && $message['key'] == 'register_no_approval_required') {
      $message['send'] = FALSE;
      return;
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.