1

I want to bulk create about 2-300 users with Drush on a Drupal 8 site. I want each of them to receive a welcome email and be forced to set up their own passwords. This can be done trivially with the "Notify user of new account" option through the UI but I cannot seem to make it work with Drush 9.

I can run a script that reads from a CSV and creates the user, then gives them the needed roles, however, the only option I can find for notifying the users: '--notify' throws a notify-send command failed error that appears to be related to Ubuntu notifications?

Is there some way to send a new account an email that I am missing?

6
  • 1
    What do you mean "appears related to Ubuntu notifications"? Where is the drush you are running? (Are you running drush locally or sshing into the server and running it there?) Jul 12 '21 at 6:51
  • It's Drush 9, running on an ubuntu server.
    – tanbog
    Jul 13 '21 at 3:37
  • When running with the --notify option the emailing fails and the following warning returns: [warning] notify-send command failed. Please install it as per http://coderstalk.blogspot.com/2010/02/how-to-install-notify-send-in-ubuntu.html.
    – tanbog
    Jul 13 '21 at 3:38
  • Visiting that web address you find a guide to installing a a library for Ubuntu desktop notifications. I assumed the "notify" option was not the correct one to send an email but I can't find good documentation on how it should be done.
    – tanbog
    Jul 13 '21 at 3:39
  • 1
    Have you looked at Bulk User Registration? drupal.org/project/bulk_user_registration
    – Beau
    Jul 14 '21 at 15:30
0

This is probably not the "right" way to do this, but it solved my problem.

Drush wont email on your behalf but it will generate the one time link.

You can see details here, the basic format is:

drush user:login --mail=user@example.org

One downside is that the link generated appears to not use the name of the domain generating it. So instead of links starting with https://my=site.com/user... you get: http//default/user

There is probably some environmental variable that could be changed to fix this but it seemed easier to just cut the first 13 chars with a script and replace them with the correct domain.

If you're bulk importing you can have whatever script you have written to submit the new users also generate this link and then re-write it correctly before outputing it all to a csv file (or format of your choice.)

Then you can create your own emails in whatever bulk email system you wish with a mail merge.

This solution is not ideal but it is reasonably quick and easy and not a lot can go wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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