bug #34954 [Mailer] Fixed undefined index when sending via Mandrill API (wulff)

This PR was merged into the 4.4 branch.

Discussion
----------

[Mailer] Fixed undefined index when sending via Mandrill API

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #34892
| License       | MIT

When a [Mandrill API send request](https://www.mandrillapp.com/api/docs/messages.JSON.html#method=send) 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.

Commits
-------

ef0aa4dc87 [Mailer] fixed undefined index when sending mail
This commit is contained in:
Nicolas Grekas 2019-12-17 11:26:47 +01:00
commit 07bfe6bae5

View File

@ -57,7 +57,8 @@ class MandrillApiTransport extends AbstractApiTransport
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;
}