Describe your bug or feature request.

While sending an Order Confirmation with the new symfony_mailer I got this notice:
Notice: Undefined index: to in Drupal\commerce_log\EventSubscriber\OrderMailEventSubscriber->onMailSend() (line 82 of /xxx/drupal/web/modules/contrib/commerce/modules/log/src/EventSubscriber/OrderMailEventSubscriber.php).
The mail is sent with the correct content.

Comments

PROMES created an issue. See original summary.

drcolossos’s picture

Status: Active » Needs work

Can confirm that this issue exists with the new symfony_mailer module. But it might be an issue with symfony_mailer

balis_m’s picture

I can confirm too that this issue exists with the new symfony_mailer module.

I solved it with this patch.

jsacksick’s picture

This is weird: Drupal\Core\Mail\MailManager::doMail() has the following code:

    $message = [
      'id' => $module . '_' . $key,
      'module' => $module,
      'key' => $key,
      'to' => $to,
      'from' => $site_mail,
      'reply-to' => $reply,
      'langcode' => $langcode,
      'params' => $params,
      'send' => TRUE,
      'subject' => '',
      'body' => [],
    ];

Which is the method that's invoked when Commerce calls

    $message = $this->mailManager->mail('commerce', $params['id'], $to, $params['langcode'], $params, $params['reply-to']);

Are you decorating the mail manager by any chance? Or is it decorated by a contrib module you're using? Because $message['to'] should always be defined.

promes’s picture

The only change I made is using a changed copy of postada-order-receipt.html.twig in a custom module.
With patch #3 the mail is arriving.

jsacksick’s picture

Status: Needs work » Needs review
StatusFileSize
new617 bytes

Ok, I've tried this myself and this is due to the symfony_mailer_bc module not sending back the "to" key in Drupal\symfony_mailer_bc\MailManagerReplacement.

The attached patch does the trick (similar to #3, with an additional comment).

jsacksick’s picture

Status: Needs review » Fixed

Committed.

  • jsacksick committed 7e636f3 on 8.x-2.x
    Issue #3250480 by balis_m, jsacksick: Fix undefined index to in...

  • jsacksick committed cee6a5d on 3.0.x
    Issue #3250480 by balis_m, jsacksick: Fix undefined index to in...
sebastix’s picture

Just ran into the same problem, patch in comment #6 fixed it.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.