Skip to content

Commit 2ba8f16

Browse files
committed
[Mailer] Use better error code when auth fails
1 parent 6eef692 commit 2ba8f16

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,15 @@ private function handleAuth(array $modes): void
180180
continue;
181181
}
182182

183+
$code = 535;
183184
$authNames[] = $authenticator->getAuthKeyword();
184185
try {
185186
$authenticator->authenticate($this);
186187

187188
return;
188189
} catch (TransportExceptionInterface $e) {
190+
$code = $e->getCode();
191+
189192
try {
190193
$this->executeCommand("RSET\r\n", [250]);
191194
} catch (TransportExceptionInterface) {
@@ -206,6 +209,6 @@ private function handleAuth(array $modes): void
206209
$message .= sprintf(' Authenticator "%s" returned "%s".', $name, $error);
207210
}
208211

209-
throw new TransportException($message);
212+
throw new TransportException($message, $code);
210213
}
211214
}

0 commit comments

Comments
 (0)