From 1cdce3d5a0e82682c7759c8d3ede7765b4b4f037 Mon Sep 17 00:00:00 2001 From: Maksym Kuzomko Date: Wed, 8 Feb 2017 23:01:42 +0200 Subject: [PATCH 1/2] Issue #2848322 "Rules send mail action doesn't work if the email of recipient is a reference to an email field". --- src/Plugin/RulesAction/SystemSendEmail.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Plugin/RulesAction/SystemSendEmail.php b/src/Plugin/RulesAction/SystemSendEmail.php index e8cc4b8c..aef82ae9 100644 --- a/src/Plugin/RulesAction/SystemSendEmail.php +++ b/src/Plugin/RulesAction/SystemSendEmail.php @@ -110,6 +110,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, From ca9792f27ead157a3071ae7958fc24fd9c52f520 Mon Sep 17 00:00:00 2001 From: Maksym Kuzomko Date: Tue, 7 Mar 2017 08:57:04 +0200 Subject: [PATCH 2/2] Issue #2848322 "Rules send mail action doesn't work if the email of recipient is a reference to an email field". --- src/Plugin/RulesAction/SystemSendEmail.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Plugin/RulesAction/SystemSendEmail.php b/src/Plugin/RulesAction/SystemSendEmail.php index aef82ae9..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;