function EsmtpTransport::handleAuth
1 call to EsmtpTransport::handleAuth()
- EsmtpTransport::doEhloCommand in vendor/
symfony/ mailer/ Transport/ Smtp/ EsmtpTransport.php
File
-
vendor/
symfony/ mailer/ Transport/ Smtp/ EsmtpTransport.php, line 203
Class
- EsmtpTransport
- Sends Emails over SMTP with ESMTP support.
Namespace
Symfony\Component\Mailer\Transport\SmtpCode
private function handleAuth(array $modes) : void {
if (!$this->username) {
return;
}
$code = null;
$authNames = [];
$errors = [];
$modes = array_map('strtolower', $modes);
foreach ($this->authenticators as $authenticator) {
if (!\in_array(strtolower($authenticator->getAuthKeyword()), $modes, true)) {
continue;
}
$code = null;
$authNames[] = $authenticator->getAuthKeyword();
try {
$authenticator->authenticate($this);
return;
} catch (UnexpectedResponseException $e) {
$code = $e->getCode();
try {
$this->executeCommand("RSET\r\n", [
250,
]);
} catch (TransportExceptionInterface) {
// ignore this exception as it probably means that the server error was final
}
// keep the error message, but tries the other authenticators
$errors[$authenticator->getAuthKeyword()] = $e->getMessage();
}
}
if (!$authNames) {
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, $code ?: 535);
}