8000 [Mailer] Fix error message in case of an STMP error · symfony/symfony@7ecebff · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ecebff

Browse files
committed
[Mailer] Fix error message in case of an STMP error
1 parent 42938ef commit 7ecebff

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransport.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ protected function doHeloCommand(): void
120120
$response = $this->executeCommand(sprintf("EHLO %s\r\n", $this->getLocalDomain()), [250]);
121121
$capabilities = $this->getCapabilities($response);
122122
} catch (TransportExceptionInterface $e) {
123-
parent::doHeloCommand();
123+
try {
124+
parent::doHeloCommand();
125+
} catch (TransportExceptionInterface $ex) {
126+
if (!$ex->getCode()) {
127+
throw $e;
128+
}
129+
}
124130

125131
return;
126132
}

src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,12 @@ private function assertResponseCode(string $response, array $codes): void
295295
throw new LogicException('You must set the expected response code.');
296296
}
297297

298-
if (!$response) {
299-
throw new TransportException(sprintf('Expected response code "%s" but got an empty response.', implode('/', $codes)));
300-
}
301-
302298
[$code] = sscanf($response, '%3d');
303299
$valid = \in_array($code, $codes);
304300

305301
if (!$valid) {
306-
throw new TransportException(sprintf('Expected response code "%s" but got code "%s", with message "%s".', implode('/', $codes), $code, trim($response)), $code);
302+
$extra = $response ? sprintf(', with message "%s"', trim($response)) : '';
303+
throw new TransportException(sprintf('Expected response code "%s" but got code "%s"%s.', implode('/', $codes), $code, $extra), $code);
307304
}
308305
}
309306

0 commit comments

Comments
 (0)
0