Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,15 @@ private function handleAuth(array $modes): void
continue;
}

$code = null;
$authNames[] = $authenticator->getAuthKeyword();
try {
$authenticator->authenticate($this);

return;
} catch (TransportExceptionInterface $e) {
$code = $e->getCode();

try {
$this->executeCommand("RSET\r\n", [250]);
} catch (TransportExceptionInterface) {
Expand All @@ -198,14 +201,14 @@ private function handleAuth(array $modes): void
}

if (!$authNames) {
throw new TransportException(sprintf('Failed to find an authenticator supported by the SMTP server, which currently supports: "%s".', implode('", "', $modes)));
throw new TransportException(sprintf('Failed to find an authenticator supported by the SMTP server, which currently supports: "%s".', implode('", "', $modes)), $code ?: 504);
}

$message = sprintf('Failed to authenticate on SMTP server with username "%s" using the following authenticators: "%s".', $this->username, implode('", "', $authNames));
foreach ($errors as $name => $error) {
$message .= sprintf(' Authenticator "%s" returned "%s".', $name, $error);
}

throw new TransportException($message);
throw new TransportException($message, $code ?: 535);
}
}