diff --git a/src/Smtp/AsyncSmtpConnectionWriter.php b/src/Smtp/AsyncSmtpConnectionWriter.php index 0077f62..aa84037 100644 --- a/src/Smtp/AsyncSmtpConnectionWriter.php +++ b/src/Smtp/AsyncSmtpConnectionWriter.php @@ -110,8 +110,9 @@ private function processDataResponse(string $data): void $this->dataProcessingPromise = new \React\Promise\Deferred(); $this->logger->debug('RECEIVED DATA: ' . $data); + if (count($this->expectedResponses) === 0) { - throw new \AsyncConnection\Smtp\AsyncSmtpConnectionException(sprintf('Received unexpected data from server: %s.', $data)); + return; } [$deferred, $expectedCodes, $message, $messageToReplace] = array_shift($this->expectedResponses); diff --git a/tests/Smtp/AsyncSmtpConnectionWriterTest.php b/tests/Smtp/AsyncSmtpConnectionWriterTest.php index b9b5162..db679d0 100644 --- a/tests/Smtp/AsyncSmtpConnectionWriterTest.php +++ b/tests/Smtp/AsyncSmtpConnectionWriterTest.php @@ -58,15 +58,6 @@ public function testInvalidStreamThrowsException(): void new AsyncSmtpConnectionWriter($connectionMock, $this->logger); } - public function testUnexpectedDataThrowException(): void - { - $this->expectException(\AsyncConnection\Smtp\AsyncSmtpConnectionException::class); - $this->expectExceptionMessage('Received unexpected data from server: 333 unexpectedServerResponse.'); - - new AsyncSmtpConnectionWriter($this->createConnectionMock(), $this->logger); - $this->runFailedTest('333 unexpectedServerResponse'); - } - public function testUnexpectedConnectionEndFromServer(): void { $writer = new AsyncSmtpConnectionWriter($this->createConnectionMock(), $this->logger);