Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EsmtpTransport.php

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\Smtp

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal