diff --git a/lib/Mailer/MailerError.php b/lib/Mailer/MailerError.php index 23acb3cb84..e646b7c201 100644 --- a/lib/Mailer/MailerError.php +++ b/lib/Mailer/MailerError.php @@ -8,6 +8,8 @@ class MailerError { const LEVEL_HARD = 'hard'; const LEVEL_SOFT = 'soft'; + const MESSAGE_EMAIL_NOT_AUTHORIZED = 'The email address is not authorized'; + /** @var string */ private $operation; diff --git a/tests/integration/Mailer/Methods/ErrorMappers/MailPoetMapperTest.php b/tests/integration/Mailer/Methods/ErrorMappers/MailPoetMapperTest.php index aa036637dd..f70c99e83f 100644 --- a/tests/integration/Mailer/Methods/ErrorMappers/MailPoetMapperTest.php +++ b/tests/integration/Mailer/Methods/ErrorMappers/MailPoetMapperTest.php @@ -59,6 +59,20 @@ class MailPoetMapperTest extends \MailPoetTest { )); } + function testGetErrorUnauthorizedEmail() { + $api_result = [ + 'code' => API::RESPONSE_CODE_CAN_NOT_SEND, + 'status' => API::SENDING_STATUS_SEND_ERROR, + 'message' => MailerError::MESSAGE_EMAIL_NOT_AUTHORIZED, + ]; + $error = $this->mapper->getErrorForResult($api_result, $this->subscribers); + + expect($error)->isInstanceOf(MailerError::class); + expect($error->getOperation())->equals(MailerError::OPERATION_SEND); + expect($error->getLevel())->equals(MailerError::LEVEL_HARD); + expect($error->getMessage())->contains('The MailPoet Sending Service did not send your latest email because the address'); + } + function testGetErrorPayloadTooBig() { $api_result = [ 'code' => API::RESPONSE_CODE_PAYLOAD_TOO_BIG,