Disable User Registration Emails

Profile picture for user Phil Frilling
By Phil Frilling, 3 August, 2012
Today I was setting up a shopping cart with Ubercart and Drupal 7 and I noticed that I was getting two registration emails. One from the Drupal user module that said:
USERNAME,

Thank you for registering at SITE_NAME. You may now log in by clicking
this link or copying and pasting it to your browser:

http://SITE_URL/user/reset/169/1344015675/vo2a354aGJd7ipVI8YKlTgetVEu65k3jW9P9nkxoynQ

This link can only be used once to log in and will lead you to a page where
you can set your password.

After setting your password, you will be able to log in at
http://SITE_URL/user in the future using:

username: USERNAME
password: Your password

--  SITE_NAME team
This was fine except that the order confirmation email that got sent contained the normal order information and the new username / password, which was confusing our users.
An account has been created for you with the following details:
Username: USERNAME
Password: PASSWORD

How to disable the default registration email notification

Here's how to stop the registration email from being sent. Using hook_mail_alter(), we can intercept the message and prevent it from being sent. (http://drupal.org/node/257202#comment-1182313)

function MYMODULE_mail_alter(&$message){
  if ($message['id'] == 'user_register_no_approval_required') {
    watchdog('My Module Name', 'registration email not sent.');
    $message['send'] = FALSE;
    return;
  }
}