I'm working in Drupal 8.2.4 currently and building a headless webapp using Rest Web Services module for the endpoints I need.
I'm using the endpoint /entity/user
to create users, however the default welcome emails are not getting sent out by Drupal when I create the users.
I do have the emails set up to be sent properly and I know this because if I create a user like normal in Drupal with "Notify user of new account" checked, it does send the email. Is there some simple way that I am just missing to get this to work?
I have also tried using hook_ENTITY_TYPE_insert
using _user_mail_notify
to trigger the email to be sent, however this is not working either for what I want. My code is as follows:
/**
* Implements hook_ENTITY_TYPE_insert().
* When a new user is created, do things.
*/
function custom_rules_user_insert(Drupal\Core\Entity\EntityInterface $entity)
{
_user_mail_notify('register_no_approval_required', $entity);
}
Am I doing something wrong, is there a simple way to get this to work or does this just not work at all yet in Drupal 8? I will also need to set up Pass Reset emails, so any feedback would be appreciated.