Search code examples
drupaldrupal-6

How do I send an email notification when programatically creating a Drupal user?


I am trying to create a user using code. I have the following that created the user. It however does not send an email to the user saying that the account has been created. How can I do that?

$newUser = array(
  'name' => 'username',
  'pass' => 'password', // note: do not md5 the password
  'mail' => 'email address',
  'status' => 1,
  'init' => 'email address'
);           
user_save(null, $newUser);

Solution

  • You could use Rules. You can add an action to be fired when user is created.