- Issue created by @gbmapo
- đŠđĒGermany simonbaese Berlin
Thank you for the report. This is probably related to đ Remove '__disable_customize__' parameters while queuing legacy emails Active . I will check it out soon once client work is less busy.
- đĢđˇFrance gbmapo
I did another try after converting all my custom modules to use Level 3 Native implementation of Drupal Symfony Mailer.
Everything works fine when I don't use Symfony Mailer Queue.When I use it, it doesn't âšī¸
The log of the cron job (Queue: Sends emails and retries failures) says:Warning: Undefined array key 0 in Drupal\amap\Plugin\EmailBuilder\EmailBuilder->createParams() (line 37 of /var/www/html/web/modules/custom/amap/src/Plugin/EmailBuilder/EmailBuilder.php) @backtrace_string. Warning: Undefined array key 1 in Drupal\amap\Plugin\EmailBuilder\EmailBuilder->createParams() (line 45 of /var/www/html/web/modules/custom/amap/src/Plugin/EmailBuilder/EmailBuilder.php) @backtrace_string. TypeError: Drupal\symfony_mailer\MailerHelper::parseAddress(): Argument #1 ($encoded) must be of type string, null given, called in /var/www/html/web/modules/custom/amap/src/Plugin/EmailBuilder/EmailBuilder.php on line 72 in Drupal\symfony_mailer\MailerHelper->parseAddress() (line 101 of /var/www/html/web/modules/contrib/symfony_mailer/src/MailerHelper.php).
The good thing is that the correct EmailBuilder is called.
The problem is that the parameters of the email aren't sent from the queue.
Sorry, I couldn't debug further... - đĢđˇFrance gbmapo
I tried again after upgrading Drupal Symfony Mailer to 1.6.0.
I still have the errors related to EmailBuilder not getting the emails parameters.Warning: Undefined array key 0 in Drupal\amap\Plugin\EmailBuilder\EmailBuilder->createParams() (line 37 of modules/custom/amap/src/Plugin/EmailBuilder/EmailBuilder.php). Warning: Undefined array key 1 in Drupal\amap\Plugin\EmailBuilder\EmailBuilder->createParams() (line 41 of modules/custom/amap/src/Plugin/EmailBuilder/EmailBuilder.php). Warning: Undefined array key 2 in Drupal\amap\Plugin\EmailBuilder\EmailBuilder->createParams() (line 42 of modules/custom/amap/src/Plugin/EmailBuilder/EmailBuilder.php).
- đĢđˇFrance gbmapo
I tried to debug a little and here are my findings:
In my custom module, I send emails with:
$emailFactory = \Drupal::service('email_factory'); $sTo = $user->getEmail(); $email = $emailFactory->newTypedEmail('amap', $key, $sTo, $sNextWednesday, $D);
In my EmailBuilder, I have
public function createParams(EmailInterface $email, ...$myParams) { $email->setParam('to', $myParams[0]); $email->setParam('distributiondate', $myParams[1]); $email->setParam('numberofamapiens', $myParams[2]); }
and it works fine when emails are sent directly (not with Symfony Mailer Queue) because in createParams() of EmailBuilder, $myParams is equal to
Array ( [0] => abc@free.fr [1] => 4 juin 2025 [2] => 2 )
If I sent the same emails with Symfony Mailer Queue, when I run the cron job 'Queue: Sends emails and retries failures', I get the errors I mentioned previously [Undefined array key 0 in Drupal\amap\Plugin\EmailBuilder\EmailBuilder->createParams()], because at that point, $myParams is equal to
Array ( [to] => eric.falzon@free.fr [distributiondate] => 4 juin 2025 [numberofamapiens] => 2 )
I understand that the error is coming from the difference of the keys ot the array $myParams in the two cases.
I know that I can update my EmailBuilder to handle this, but my question is:
Why doesn't Symfony Mailer Queue return exactly what it has in input, (an array with keys 0, 1, 2, ... in this case)? - Merge request !2Issue #3513019: Store original email parameters and reinitialize in queue worker â (Merged) created by simonbaese
- đŠđĒGermany simonbaese Berlin
@gbmapo Thank you for the detailed report and the additional findings from your investigation. This is very helpful to understand the problem.
The Symfony Mailer module alters the email parameters, not the Symfony Mailer Queue module. Yet, the queue worker sends the email through the processing of Symfony Mailer again. To circumvent problems with altered parameters, we now reinitialize the email in the queue worker with the original parameters.
Can you please check whether this solves your issues? Additionally, could you please review the code changes?
- đĢđˇFrance gbmapo
I patched my installed version of Symfony Mailer Queue with your changes in your merge request !2 and rerun my set of tests.
I'm glad to announce that it works!
Thanks a lot. -
simonbaese â
committed ccf9ba09 on 1.2.x
Issue #3513019 by simonbaese, gbmapo: Store original email parameters...
-
simonbaese â
committed ccf9ba09 on 1.2.x
- đŠđĒGermany simonbaese Berlin
@gbmapo Thanks again for the support. The changes will be part of the next minor release. Please use the
1.2.x
development branch until then.