Skip to content

Commit 4fd5f27

Browse files
cedric-annejaviereguiluz
authored andcommitted
[Mailer] Document EsmtpTransport::setAuthenticators()
1 parent c2cdd5e commit 4fd5f27

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

mailer.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,29 @@ the application or when using a self-signed certificate::
286286

287287
$dsn = 'smtp://user:pass@smtp.example.com?verify_peer=0';
288288

289+
Overriding default SMTP authenticators
290+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291+
292+
By default, SMTP transports will try to login using all authentication methods
293+
available on the SMTP server, one after the other. In some cases, it may be useful
294+
to redefine the supported authentication methods to ensure that the preferred method
295+
will be used first.
296+
This can be done from ``EsmtpTransport`` constructor or using the ``setAuthenticators()`` method::
297+
298+
use Symfony\Component\Mailer\Transport\Smtp\Auth\XOAuth2Authenticator;
299+
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
300+
301+
$transport = new EsmtpTransport(
302+
host: 'oauth-smtp.domain.tld',
303+
authenticators: [new XOAuth2Authenticator()]
304+
);
305+
$transport->setAuthenticators([new XOAuth2Authenticator()]);
306+
307+
.. versionadded:: 6.3
308+
309+
The ``$authenticators`` constructor parameter and the ``setAuthenticators()`` method
310+
were introduced in Symfony 6.3.
311+
289312
Other Options
290313
~~~~~~~~~~~~~
291314

0 commit comments

Comments
 (0)