fromArray() on null in MailManagerReplacement->mail()

Created on 6 October 2023, about 1 year ago
Updated 24 January 2024, 10 months ago

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',
    );
πŸ’¬ Support request
Status

Closed: works as designed

Version

2.1

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium davidiio

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

Comments & Activities

Production build 0.71.5 2024