diff options
author | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2018-04-24 10:25:08 +0000 |
---|---|---|
committer | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2018-04-24 10:25:08 +0000 |
commit | 584d863385257d70aa2d9d826f531205c92d95ea (patch) | |
tree | 9aaaf133f8c1b16a7284852e651ce20d92d5c612 /Postman | |
parent | 2f78b52b85b9762c61636aec11fa1418f2174833 (diff) | |
download | Post-SMTP-584d863385257d70aa2d9d826f531205c92d95ea.zip |
Sendgrid bug -status code
git-svn-id: https://plugins.svn.wordpress.org/post-smtp/trunk@1863530 b8457f37-d9ea-0310-8a92-e5e31aec5664
Diffstat (limited to 'Postman')
-rw-r--r-- | Postman/Postman-Mail/PostmanSendGridMailEngine.php | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/Postman/Postman-Mail/PostmanSendGridMailEngine.php b/Postman/Postman-Mail/PostmanSendGridMailEngine.php index cf652a8..b6082f9 100644 --- a/Postman/Postman-Mail/PostmanSendGridMailEngine.php +++ b/Postman/Postman-Mail/PostmanSendGridMailEngine.php @@ -188,12 +188,12 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { $response_body = json_decode( $response->body() ); - $error_code = $response->statusCode(); - $email_not_sent = $error_code != 202; + $response_code = $response->statusCode(); + $email_sent = ( $response_code >= 200 and $response_code < 300 ); - if ( isset( $response_body->errors[0]->message ) || $email_not_sent ) { + if ( isset( $response_body->errors[0]->message ) || ! $email_sent ) { - $e = $email_not_sent ? $this->errorCodesMap($error_code) : $response_body->errors[0]->message; + $e = ! $email_sent ? $this->errorCodesMap($response_code) : $response_body->errors[0]->message; $this->transcript = $e; $this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS; $this->transcript .= print_r( $mail, true ); @@ -213,31 +213,7 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { throw $e; } } - - private function get_response_error($body) { - - $error_text = array(); - - if ( ! empty( $body['errors'] ) ) { - foreach ( $body['errors'] as $error ) { - if ( property_exists( $error, 'message' ) ) { - // Prepare additional information from SendGrid API. - $extra = ''; - if ( property_exists( $error, 'field' ) && ! empty( $error->field ) ) { - $extra .= $error->field . '; '; - } - if ( property_exists( $error, 'help' ) && ! empty( $error->help ) ) { - $extra .= $error->help; - } - - // Assign both the main message and perhaps extra information, if exists. - $error_text[] = $error->message . ( ! empty( $extra ) ? ' - ' . $extra : '' ); - } - } - } - - return implode( '<br>', array_map( 'esc_textarea', $error_text ) ); - } + private function errorCodesMap($error_code) { switch ($error_code) { |