diff --git a/src/Plugin/RulesAction/SystemSendEmail.php b/src/Plugin/RulesAction/SystemSendEmail.php index e8cc4b8c..82318566 100644 --- a/src/Plugin/RulesAction/SystemSendEmail.php +++ b/src/Plugin/RulesAction/SystemSendEmail.php @@ -5,6 +5,7 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Mail\MailManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\Field\FieldItemList; use Drupal\rules\Core\RulesActionBase; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -110,6 +111,15 @@ public static function create(ContainerInterface $container, array $configuratio * (optional) Language code. */ protected function doExecute($to, $subject, $message, $reply = NULL, LanguageInterface $language = NULL) { + if ($to instanceof FieldItemList) { + $items = $to->getValue(); + $to = []; + + foreach ($items as $item) { + $to[] = reset($item); + } + } + $langcode = isset($language) ? $language->getId() : LanguageInterface::LANGCODE_SITE_DEFAULT; $params = [ 'subject' => $subject,