diff --git a/SmsapiTransport.php b/SmsapiTransport.php index 79df322..976baa4 100644 --- a/SmsapiTransport.php +++ b/SmsapiTransport.php @@ -65,10 +65,10 @@ protected function doSend(MessageInterface $message): SentMessage ], ]); - if (200 !== $response->getStatusCode()) { - $error = $response->toArray(false); + $responseContent = $response->toArray(false); - throw new TransportException(sprintf('Unable to send the SMS: "%s".', $error['message']), $response); + if ((isset($responseContent['error']) && null !== $responseContent['error']) || (200 !== $response->getStatusCode()) ) { + throw new TransportException(sprintf('Unable to send the SMS: "%s".', $responseContent['message']), $response); } return new SentMessage($message, (string) $this);