From 44d5b574b6b55264890f7340820f206a909b38f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Barton=C3=AD=C4=8Dek?= Date: Wed, 20 Dec 2023 13:56:50 +0100 Subject: [PATCH] [Mailer] Throw TransportException when unable to read from socket --- .../Mailer/Transport/Smtp/Stream/AbstractStream.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php b/src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php index 4cfcd8b5441c1..c53f8b54ee505 100644 --- a/src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php +++ b/src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php @@ -74,7 +74,7 @@ public function readLine(): string return ''; } - $line = fgets($this->out); + $line = @fgets($this->out); if ('' === $line || false === $line) { $metas = stream_get_meta_data($this->out); if ($metas['timed_out']) { @@ -83,6 +83,9 @@ public function readLine(): string if ($metas['eof']) { throw new TransportException(sprintf('Connection to "%s" has been closed unexpectedly.', $this->getReadConnectionDescription())); } + if (false === $line) { + throw new TransportException(sprintf('Unable to read from connection to "%s": ', $this->getReadConnectionDescription()).error_get_last()['message']); + } } $this->debug .= sprintf('< %s', $line);