views:

144

answers:

1

When a user signs up at a Drupal site, there is a configurable message that Drupal will send the user letting them know their username and password.

I have about 1,000 users that I imported, but at the time, I didn't want to notify them - but now I do. Is there a way notify the users without reimporting them?

I looked through some of the modules I thought might contain that function, but I couldn't find it??

+6  A: 

Ofcourse there's a way. If you're going to this operation just one time, I recommend you to use a quick easy way, drupal_bootstrap(). In an external php file make use of this function to bootstrap Drupal:

...
chdir(../../); // Change directory to drupal root.
require './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // Also you can pass DRUPAL_BOOTSTRAP_DATABASE.

$db_result = db_query('SELECT * FROM {users}');
while($user_object = db_fetch_object($db_result)){
    // TODO: Making use of drupal_mail() to send desired emails.
    // User Name: $user_object->name
    // User Email: $user_object->email
    // Don't forget to pass 'em through the check_plain()
    ...
}
...

Read more at Drupal API: drupal_mail() drupal_bootstrap().

Sepehr Lajevardi
Just curious, will this allow you to email the user his/her password (as the question asked)?
Dan U.
Using this we can send users a new password, not the stored one ofcourse. Also we can make a automatic login url containing a hash, letting users to reset their passwords as drupal does by default.
Sepehr Lajevardi