diff --git a/externals/amazon-ses/ses.php b/externals/amazon-ses/ses.php --- a/externals/amazon-ses/ses.php +++ b/externals/amazon-ses/ses.php @@ -506,11 +506,28 @@ $this->response->code = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($this->response->code != 200) { - throw new SimpleEmailServiceException( - pht( - 'Unexpected HTTP status while making request to Amazon SES: '. - 'expected 200, got %s.', - $this->response->code)); + if (isset($this->response->body)) { + $parsed_body = simplexml_load_string($this->response->body); + if ($parsed_body !== false and isset($parsed_body->Error)) { + $error = $parsed_body->Error; + + throw new SimpleEmailServiceException( + pht( + 'Error while making request to Amazon SES: '. + 'Status code: %s. Amazon error info: '. + 'Type: %s, Code: %s. Message: %s.', + $this->response->code, + $error->Type, + $error->Code, + $error->Message)); + } + } else { + throw new SimpleEmailServiceException( + pht( + 'Unexpected HTTP status while making request to Amazon SES: '. + 'expected 200, got %s.', + $this->response->code)); + } } @curl_close($curl); @@ -518,22 +535,6 @@ // Parse body into XML if ($this->response->error === false && isset($this->response->body)) { $this->response->body = simplexml_load_string($this->response->body); - - // Grab SES errors - if (!in_array($this->response->code, array(200, 201, 202, 204)) - && isset($this->response->body->Error)) { - $error = $this->response->body->Error; - $output = array(); - $output['curl'] = false; - $output['Error'] = array(); - $output['Error']['Type'] = (string)$error->Type; - $output['Error']['Code'] = (string)$error->Code; - $output['Error']['Message'] = (string)$error->Message; - $output['RequestId'] = (string)$this->response->body->RequestId; - - $this->response->error = $output; - unset($this->response->body); - } } return $this->response;