Hi everyone,
We are trying to use easy_email and we are facing an error I don't understand so I am asking for help here.
We are using drupal 9.5.11, symfony_mailer 1.3.2 and easy_email 2.1.x-dev (also tried 2.1.0 beta, had same issue)
I have created a custom module with a .emails.yml file, I have created a template in admin interface and an override.
Emails are sent with token replacement fields are used and it looks OK except that an error is raised at some point so final result depend on where I send the mail from:
- when I send email from an evensubscriber, mail is sent error is in log but final result is not blocking.
- When send email from a controller, mail is sent, controller is stopped and user is faced with white screen with error message.
- When send email from a hook_cron, email is sent, cron is interupted by error, following tasks are not run.
Here is the error message I get:
Error : Call to a member function fromArray() on null dans Drupal\symfony_mailer\MailManagerReplacement->mail() (/home/my_site/public_html/web/modules/contrib/symfony_mailer/src/MailManagerReplacement.php ligne 89)
#0 /home/my_site/public_html/web/modules/contrib/easy_email/modules/easy_email_override/src/Service/MailManager.php(87): Drupal\symfony_mailer\MailManagerReplacement->mail()
#1 /home/my_site/public_html/web/modules/_custom/my_module/src/Controller/TestController.php(44): Drupal\easy_email_override\Service\MailManager->mail()
#2 [internal function]: Drupal\my_module\Controller\TestController->mailTest()
it looks like $builder
variable is NULL but I don't understand why.
I came here to ask for help because event if the error is raised by symfony_mailer, other system emails work OK and only the one using easy-email is giving this error.
Here are the simplified emails.yml config and email sending snippet. Like I said, even with other fields mail is sent, maybe something else is missing for symfony_mailer? If anyone can help me with information on how to debug this it would be very much appreciated.
Thanks
my_module.test:
id: 'my_module.test'
label: 'Un mail de test'
module: 'my_module'
key: 'test'
params:
account:
type: 'entity:user'
label: 'Account'
\Drupal::service('plugin.manager.mail')->mail(
'my_module', //module
'test', //key
'mytestemailaddress@gmail.com', //to
$user->getPreferredLangcode(), //langcode
[
'from' => 'mysiteemail@mysite.be',
'account' => $user,
],
'mysiteemail@mysite.be',
);
Closed: works as designed
2.1
Code