Recipe for sending ECA emails w/ Easy Email

Created on 18 September 2024, 7 months ago

Problem/Motivation

I have been attempting to find a solution to sending emails in HTML format using ECA, and came across recommendations to use this module. I have not been able to find a configuration that works and hope someone can provide a set of steps to have ECA generate an HTML email using Easy Email

Steps to reproduce

Create an email template in Easy Email. Set a Unique Key Pattern. Add a recipient, sender, subject, and html Body.

From here I tried adding an ECA action using the Send Easy Email template. I tried various permutations, first going straight to sending the email, then attempting to first create an email entity. It wasn't clear to me whether to use the Unique Key Pattern or the Mail Key, so I tried both. None of these worked. Emails never were delivered, and the following turned up in the Log:

TypeError: Drupal\easy_email\Service\EmailHandler::sendEmail(): Argument #1 ($email) must be of type Drupal\easy_email\Entity\EasyEmailInterface, null given, called in /app/web/modules/contrib/easy_email/src/Plugin/Action/SendEasyEmail.php on line 66 in Drupal\easy_email\Service\EmailHandler->sendEmail() (line 153 of /app/web/modules/contrib/easy_email/src/Service/EmailHandler.php).

#0 /app/web/modules/contrib/easy_email/src/Plugin/Action/SendEasyEmail.php(66): Drupal\easy_email\Service\EmailHandler->sendEmail(NULL)
#1 /app/web/modules/contrib/eca/src/Entity/Objects/EcaAction.php(106): Drupal\easy_email\Plugin\Action\SendEasyEmail->execute(NULL)
#2 /app/web/modules/contrib/eca/src/Processor.php(290): Drupal\eca\Entity\Objects\EcaAction->execute(Object(Drupal\eca\Entity\Objects\EcaAction), Object(Drupal\flag\Event\FlaggingEvent), Array)
#3 /app/web/modules/contrib/eca/src/Processor.php(292): Drupal\eca\Processor->executeSuccessors(Object(Drupal\eca\Entity\Eca), Object(Drupal\eca\Entity\Objects\EcaAction), Object(Drupal\flag\Event\FlaggingEvent), Array)
#4 /app/web/modules/contrib/eca/src/Processor.php(292): Drupal\eca\Processor->executeSuccessors(Object(Drupal\eca\Entity\Eca), Object(Drupal\eca\Entity\Objects\EcaAction), Object(Drupal\flag\Event\FlaggingEvent), Array)
#5 /app/web/modules/contrib/eca/src/Processor.php(221): Drupal\eca\Processor->executeSuccessors(Object(Drupal\eca\Entity\Eca), Object(Drupal\eca\Entity\Objects\EcaEvent), Object(Drupal\flag\Event\FlaggingEvent), Array)
#6 /app/web/modules/contrib/eca/src/EventSubscriber/DynamicSubscriber.php(39): Drupal\eca\Processor->execute(Object(Drupal\flag\Event\FlaggingEvent), 'flag.entity_fla...')
#7 [internal function]: Drupal\eca\EventSubscriber\DynamicSubscriber->onEvent(Object(Drupal\flag\Event\FlaggingEvent), 'flag.entity_fla...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#8 /app/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Drupal\flag\Event\FlaggingEvent), 'flag.entity_fla...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#9 /app/web/modules/contrib/flag/src/Entity/Flagging.php(197): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Drupal\flag\Event\FlaggingEvent), 'flag.entity_fla...')
#10 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(563): Drupal\flag\Entity\Flagging->postSave(Object(Drupal\flag\Entity\Storage\FlaggingStorage), false)
#11 /app/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(781): Drupal\Core\Entity\EntityStorageBase->doPostSave(Object(Drupal\flag\Entity\Flagging), false)
#12 /app/web/modules/contrib/flag/src/Entity/Storage/FlaggingStorage.php(144): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object(Drupal\flag\Entity\Flagging), false)
#13 /app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(489): Drupal\flag\Entity\Storage\FlaggingStorage->doPostSave(Object(Drupal\flag\Entity\Flagging), false)
#14 /app/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(806): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\flag\Entity\Flagging))
#15 /app/web/core/lib/Drupal/Core/Entity/EntityBase.php(354): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object(Drupal\flag\Entity\Flagging))
#16 /app/web/modules/contrib/flag/src/FlagService.php(313): Drupal\Core\Entity\EntityBase->save()
#17 /app/web/modules/contrib/flag/src/Controller/ActionLinkController.php(83): Drupal\flag\FlagService->flag(Object(Drupal\flag\Entity\Flag), Object(Drupal\user\Entity\User))
#18 [internal function]: Drupal\flag\Controller\ActionLinkController->flag(Object(Drupal\flag\Entity\Flag), '1951')
#19 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#20 /app/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#21 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#22 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#23 /app/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#24 /app/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#25 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /app/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /app/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 /app/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#34 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#35 {main}

Proposed resolution

Looking for a set of steps to configure an Easy Email and then trigger it with and ECA rule. This module seems great and I suspect it can do what I want, but I am finding configuration challenging without an example out there.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Active

Version

3.0

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States ezra

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024