Skip to content

Commit 5cb8036

Browse files
committed
[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.
1 parent 0469f36 commit 5cb8036

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Mailchimp/Transport/MandrillApiTransport.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
5757
throw new HttpTransportException(sprintf('Unable to send an email (code %s).', $result['code']), $response);
5858
}
5959

60-
$sentMessage->setMessageId($result['_id']);
60+
$firstRecipient = reset($result);
61+
$sentMessage->setMessageId($firstRecipient['_id']);
6162

6263
return $response;
6364
}

MandrillApiTransport.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
5757
throw new HttpTransportException(sprintf('Unable to send an email (code %s).', $result['code']), $response);
5858
}
5959

60-
$sentMessage->setMessageId($result['_id']);
60+
$firstRecipient = reset($result);
61+
$sentMessage->setMessageId($firstRecipient['_id']);
6162

6263
return $response;
6364
}

0 commit comments

Comments
 (0)