File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -421,6 +421,35 @@ Other Options
421421
422422 The ``max_per_second `` option was introduced in Symfony 6.2.
423423
424+ Custom Transport Factories
425+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
426+
427+ If you want to support your own custom DSN (``acme://... ``), you can create a
428+ custom transport factory. To do so, create a class that implements
429+ :class: `Symfony\\ Component\\ Mailer\\ Transport\\ TransportFactoryInterface ` or, if
430+ you prefer, extend the :class: `Symfony\\ Component\\ Mailer\\ Transport\\ AbstractTransportFactory `
431+ class to save some boilerplate code::
432+
433+ // src/Mailer/AcmeTransportFactory.php
434+ final class AcmeTransportFactory extends AbstractTransportFactory
435+ {
436+ public function create(Dsn $dsn): TransportInterface
437+ {
438+ // parse the given DSN, extract data/credentials from it
439+ // and then, create and return the transport
440+ }
441+
442+ protected function getSupportedSchemes(): array
443+ {
444+ // this supports DSN starting with `acme://`
445+ return ['acme'];
446+ }
447+ }
448+
449+ After creating the custom transport class, register it as a service in your
450+ application and :doc: `tag it </service_container/tags >` with the
451+ ``mailer.transport_factory `` tag.
452+
424453Creating & Sending Messages
425454---------------------------
426455
You can’t perform that action at this time.
0 commit comments