Appearance
Notifier can automatically produce a recipient for user entities by calling AccountInterface::getEmail()
method on a user entity instance.
Service parameter
User email behavior is enabled by default. You can configure whether this is on by modifying the notifier.field_mapping.user_email
service parameter.
The parameter takes only true
or false
as its value.
For more information on service parameters, see Notifier configuration
Example
A user entity object which returns an email, will produce a recipient.
php
# Pseudo-code.
class \Drupal\user\Entity\User {
public function getEmail() {
// This method returns the value of the user entity's email field.
return 'test@example.com'
}
}
To add additional logic around the email address, consider configuring a bundle class to extend the User entity class, then override the getEmail()
method.