[Mailer] fixed Mailgun support when a response is not JSON as expected
This commit is contained in:
parent
d423b0f473
commit
3b2db425f6
@ -58,9 +58,11 @@ class MailgunTransport extends AbstractApiTransport
|
||||
]);
|
||||
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
$error = $response->toArray(false);
|
||||
if ('application/json' === $response->getHeaders(false)['content-type'][0]) {
|
||||
throw new TransportException(sprintf('Unable to send an email: %s (code %s).', $response->toArray(false)['message'], $response->getStatusCode()));
|
||||
}
|
||||
|
||||
throw new TransportException(sprintf('Unable to send an email: %s (code %s).', $error['message'], $response->getStatusCode()));
|
||||
throw new TransportException(sprintf('Unable to send an email: %s (code %s).', $response->getContent(false), $response->getStatusCode()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,9 +59,11 @@ class MailgunTransport extends AbstractHttpTransport
|
||||
]);
|
||||
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
$error = $response->toArray(false);
|
||||
if ('application/json' === $response->getHeaders(false)['content-type'][0]) {
|
||||
throw new TransportException(sprintf('Unable to send an email: %s (code %s).', $response->toArray(false)['message'], $response->getStatusCode()));
|
||||
}
|
||||
|
||||
throw new TransportException(sprintf('Unable to send an email: %s (code %s).', $error['message'], $response->getStatusCode()));
|
||||
throw new TransportException(sprintf('Unable to send an email: %s (code %s).', $response->getContent(false), $response->getStatusCode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user