Score:1

Bulk user creation and email notification

do flag

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?

cn flag
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?)
do flag
It's Drush 9, running on an ubuntu server.
do flag
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.`
do flag
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.
in flag
Have you looked at Bulk User Registration? https://www.drupal.org/project/bulk_user_registration
do flag
I did look at it but was hoping for something a little more stable than alpha as this is for a live site
Score:0
do flag

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 [email protected]

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.