Merge branch '4.3' into 4.4

* 4.3:
  [Mailer] fixed Mailgun support when a response is not JSON as expected
This commit is contained in:
Fabien Potencier 2019-09-02 17:26:08 +02:00
commit cf57ca81ee
2 changed files with 8 additions and 4 deletions

View File

@ -62,9 +62,11 @@ class MailgunApiTransport extends AbstractApiTransport
]);
if (200 !== $response->getStatusCode()) {
$error = $response->toArray(false);
if ('application/json' === $response->getHeaders(false)['content-type'][0]) {
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $response->toArray(false)['message'], $response->getStatusCode()), $response);
}
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $error['message'], $response->getStatusCode()), $response);
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $response->getContent(false), $response->getStatusCode()), $response);
}
return $response;

View File

@ -65,9 +65,11 @@ class MailgunHttpTransport extends AbstractHttpTransport
]);
if (200 !== $response->getStatusCode()) {
$error = $response->toArray(false);
if ('application/json' === $response->getHeaders(false)['content-type'][0]) {
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $response->toArray(false)['message'], $response->getStatusCode()), $response);
}
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $error['message'], $response->getStatusCode()), $response);
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $response->getContent(false), $response->getStatusCode()), $response);
}
return $response;