diff --git a/mailpoet/lib/Mailer/Methods/ErrorMappers/MailPoetMapper.php b/mailpoet/lib/Mailer/Methods/ErrorMappers/MailPoetMapper.php index 8c6a44b909..b5a29031d2 100644 --- a/mailpoet/lib/Mailer/Methods/ErrorMappers/MailPoetMapper.php +++ b/mailpoet/lib/Mailer/Methods/ErrorMappers/MailPoetMapper.php @@ -76,7 +76,7 @@ class MailPoetMapper { $resultParsed = json_decode($result['message'], true); $message = __('Error while sending.', 'mailpoet'); if (!is_array($resultParsed)) { - if ($result['error'] === API::ERROR_MESSAGE_DMRAC) { + if (isset($result['error']) && $result['error'] === API::ERROR_MESSAGE_DMRAC) { $message .= $this->getDmarcMessage($result, $sender); } else { $message .= ' ' . $result['message']; diff --git a/mailpoet/tests/integration/Mailer/Methods/MailPoetAPITest.php b/mailpoet/tests/integration/Mailer/Methods/MailPoetAPITest.php index def83af669..464f3983e7 100644 --- a/mailpoet/tests/integration/Mailer/Methods/MailPoetAPITest.php +++ b/mailpoet/tests/integration/Mailer/Methods/MailPoetAPITest.php @@ -153,7 +153,7 @@ class MailPoetAPITest extends \MailPoetTest { $url = $hasHttps ? $extraParams['one_click_unsubscribe'][$i] : $extraParams['unsubscribe_url'][$i]; expect($body[$i]['unsubscribe'])->equals(['url' => $url, 'post' => $hasHttps]); } - + expect($body[0]['meta'])->equals($extraParams['meta'][0]); expect($body[9]['meta'])->equals($extraParams['meta'][9]); } @@ -304,7 +304,8 @@ class MailPoetAPITest extends \MailPoetTest { ['sendMessages' => [ 'code' => API::RESPONSE_CODE_CAN_NOT_SEND, 'status' => API::SENDING_STATUS_SEND_ERROR, - 'message' => MailerError::MESSAGE_EMAIL_NOT_AUTHORIZED, + 'message' => API::ERROR_MESSAGE_INVALID_FROM, + 'error' => API::ERROR_MESSAGE_INVALID_FROM, ]] ); $mailer->send([$this->newsletter], [$this->subscriber]); diff --git a/mailpoet/tests/unit/Mailer/Methods/ErrorMappers/MailPoetMapperTest.php b/mailpoet/tests/unit/Mailer/Methods/ErrorMappers/MailPoetMapperTest.php index 7311477ed1..be0de175c7 100644 --- a/mailpoet/tests/unit/Mailer/Methods/ErrorMappers/MailPoetMapperTest.php +++ b/mailpoet/tests/unit/Mailer/Methods/ErrorMappers/MailPoetMapperTest.php @@ -74,7 +74,8 @@ class MailPoetMapperTest extends \MailPoetUnitTest { $apiResult = [ 'code' => API::RESPONSE_CODE_CAN_NOT_SEND, 'status' => API::SENDING_STATUS_SEND_ERROR, - 'message' => MailerError::MESSAGE_EMAIL_FORBIDDEN_ACTION, + 'message' => API::ERROR_MESSAGE_BANNED, + 'error' => API::ERROR_MESSAGE_BANNED, ]; $error = $this->mapper->getErrorForResult($apiResult, $this->subscribers); @@ -88,7 +89,8 @@ class MailPoetMapperTest extends \MailPoetUnitTest { $apiResult = [ 'code' => API::RESPONSE_CODE_CAN_NOT_SEND, 'status' => API::SENDING_STATUS_SEND_ERROR, - 'message' => MailerError::MESSAGE_EMAIL_INSUFFICIENT_PRIVILEGES, + 'message' => API::ERROR_MESSAGE_INSUFFICIENT_PRIVILEGES, + 'error' => API::ERROR_MESSAGE_INSUFFICIENT_PRIVILEGES, ]; $error = $this->mapper->getErrorForResult($apiResult, $this->subscribers); @@ -102,7 +104,8 @@ class MailPoetMapperTest extends \MailPoetUnitTest { $apiResult = [ 'code' => API::RESPONSE_CODE_CAN_NOT_SEND, 'status' => API::SENDING_STATUS_SEND_ERROR, - 'message' => MailerError::MESSAGE_EMAIL_NOT_AUTHORIZED, + 'message' => API::ERROR_MESSAGE_INVALID_FROM, + 'error' => API::ERROR_MESSAGE_INVALID_FROM, ]; $error = $this->mapper->getErrorForResult($apiResult, $this->subscribers); @@ -174,7 +177,8 @@ class MailPoetMapperTest extends \MailPoetUnitTest { $apiResult = [ 'code' => API::RESPONSE_CODE_CAN_NOT_SEND, 'status' => API::SENDING_STATUS_SEND_ERROR, - 'message' => MailerError::MESSAGE_PENDING_APPROVAL, + 'message' => API::ERROR_MESSAGE_PENDING_APPROVAL, + 'error' => API::ERROR_MESSAGE_PENDING_APPROVAL, ]; $error = $this->mapper->getErrorForResult($apiResult, $this->subscribers); expect($error)->isInstanceOf(MailerError::class);