From ef0aa4dc874f304a6a08447e3366267a20ea9982 Mon Sep 17 00:00:00 2001 From: Morten Wulff Date: Thu, 12 Dec 2019 15:05:36 +0100 Subject: [PATCH] [Mailer] fixed undefined index when sending mail When a Mandrill API request is succesful, it returns an array of results, one for each recipient. To get rid of the undefined index error, we grab the message ID from the first recipient in the array. --- .../Mailer/Bridge/Mailchimp/Transport/MandrillApiTransport.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillApiTransport.php b/src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillApiTransport.php index fb232b05209d..50fc33baaa65 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillApiTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillApiTransport.php @@ -57,7 +57,8 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e throw new HttpTransportException(sprintf('Unable to send an email (code %s).', $result['code']), $response); } - $sentMessage->setMessageId($result['_id']); + $firstRecipient = reset($result); + $sentMessage->setMessageId($firstRecipient['_id']); return $response; }