Skip to content

Commit 351a2ec

Browse files
bug symfony#59404 [Mailer] Fix SMTP stream EOF handling on Windows by using feof() (skmedix)
This PR was merged into the 6.4 branch. Discussion ---------- [Mailer] Fix SMTP stream EOF handling on Windows by using feof() | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix symfony#59351 | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Full explanation of this change here: symfony#59351 (comment) Help with tests would be appreciated. Commits ------- ed18c7c [Mailer] Fix SMTP stream EOF handling on Windows by using feof()
2 parents a981c26 + ed18c7c commit 351a2ec

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Symfony/Component/Mailer/Transport/Smtp/Stream/AbstractStream.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ public function readLine(): string
8080

8181
$line = @fgets($this->out);
8282
if ('' === $line || false === $line) {
83-
$metas = stream_get_meta_data($this->out);
84-
if ($metas['timed_out']) {
83+
if (stream_get_meta_data($this->out)['timed_out']) {
8584
throw new TransportException(sprintf('Connection to "%s" timed out.', $this->getReadConnectionDescription()));
8685
}
87-
if ($metas['eof']) {
86+
if (feof($this->out)) { // don't use "eof" metadata, it's not accurate on Windows
8887
throw new TransportException(sprintf('Connection to "%s" has been closed unexpectedly.', $this->getReadConnectionDescription()));
8988
}
9089
if (false === $line) {

0 commit comments

Comments
 (0)