Using D8 and hooks, I am able to send automatic to the current user email thanks to
BCC For drupal mail function
So, I define my message in hook_entity_update, and it is sent in hook_mail.
But I did not succeed to send a mail to someone else of the current user.
Here is the situation:
- user U1 consult a content created by user U2 (the aim is to permit to U1 to give his impression to U2 thanks to a select field). When U1 gave his impression, content is registered.
- At this step, I want to send a emal to U2 (author of this content), but since he is not the current user, I canot use “Drupal::currentuser” to retrieve the email.
So, my question is: in hook_entity_update, How to identify author of the current entity, knowing that “author” is not provided by “entity” (a DrupalCoreEntityEntityInterface) ?
Is there a specific service?