From 4fd5f27920e020dd058be16227bc6233ab761dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Fri, 14 Apr 2023 16:17:53 +0200 Subject: [PATCH] [Mailer] Document `EsmtpTransport::setAuthenticators()` --- mailer.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mailer.rst b/mailer.rst index 8552a13f999..ab4b334700e 100644 --- a/mailer.rst +++ b/mailer.rst @@ -286,6 +286,29 @@ the application or when using a self-signed certificate:: $dsn = 'smtp://user:pass@smtp.example.com?verify_peer=0'; +Overriding default SMTP authenticators +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +By default, SMTP transports will try to login using all authentication methods +available on the SMTP server, one after the other. In some cases, it may be useful +to redefine the supported authentication methods to ensure that the preferred method +will be used first. +This can be done from ``EsmtpTransport`` constructor or using the ``setAuthenticators()`` method:: + + use Symfony\Component\Mailer\Transport\Smtp\Auth\XOAuth2Authenticator; + use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport; + + $transport = new EsmtpTransport( + host: 'oauth-smtp.domain.tld', + authenticators: [new XOAuth2Authenticator()] + ); + $transport->setAuthenticators([new XOAuth2Authenticator()]); + + .. versionadded:: 6.3 + + The ``$authenticators`` constructor parameter and the ``setAuthenticators()`` method + were introduced in Symfony 6.3. + Other Options ~~~~~~~~~~~~~