You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mailer.rst
+15-34Lines changed: 15 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -359,50 +359,31 @@ Other Options
359
359
Custom Transport Factories
360
360
~~~~~~~~~~~~~~~~~~~~~~~~~~
361
361
362
-
There is a way to easily create your own custom transport factory in case you need to do something special creating the actual transport.
363
-
364
-
The new factory needs to implement :class:`Symfony\\Component\\Mailer\\Transport\\TransportFactoryInterface`. To remove some boilerplate you can even extend from :class:`Symfony\\Component\\Mailer\\Transport\\AbstractTransportFactory` which will simplify the new factory::
365
-
366
-
367
-
final class CustomTransportFactory extends AbstractTransportFactory
362
+
If you want to support your own custom DSN (``acme://...``), you can create a
363
+
custom transport factory. To do so, create a class that implements
364
+
:class:`Symfony\\Component\\Mailer\\Transport\\TransportFactoryInterface` or, if
365
+
you prefer, extend the :class:`Symfony\\Component\\Mailer\\Transport\\AbstractTransportFactory`
366
+
class to save some boilerplate code::
367
+
368
+
// src/Mailer/AcmeTransportFactory.php
369
+
final class AcmeTransportFactory extends AbstractTransportFactory
368
370
{
369
371
public function create(Dsn $dsn): TransportInterface
370
372
{
371
-
// create and return the transport
373
+
// parse the given DSN, extract data/credentials from it
374
+
// and then, create and return the transport
372
375
}
373
376
374
377
protected function getSupportedSchemes(): array
375
378
{
376
-
return ['custom_schema'];
379
+
// this supports DSN starting with `acme://`
380
+
return ['acme'];
377
381
}
378
382
}
379
383
380
-
Finally, declare the new factory in setting tag the tag `mailer.transport_factory`:
0 commit comments