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 @@ -401,6 +401,35 @@ Other Options
401401
402402 $dsn = 'smtps://smtp.example.com?max_per_second=2'
403403
404+ Custom Transport Factories
405+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
406+
407+ If you want to support your own custom DSN (``acme://... ``), you can create a
408+ custom transport factory. To do so, create a class that implements
409+ :class: `Symfony\\ Component\\ Mailer\\ Transport\\ TransportFactoryInterface ` or, if
410+ you prefer, extend the :class: `Symfony\\ Component\\ Mailer\\ Transport\\ AbstractTransportFactory `
411+ class to save some boilerplate code::
412+
413+ // src/Mailer/AcmeTransportFactory.php
414+ final class AcmeTransportFactory extends AbstractTransportFactory
415+ {
416+ public function create(Dsn $dsn): TransportInterface
417+ {
418+ // parse the given DSN, extract data/credentials from it
419+ // and then, create and return the transport
420+ }
421+
422+ protected function getSupportedSchemes(): array
423+ {
424+ // this supports DSN starting with `acme://`
425+ return ['acme'];
426+ }
427+ }
428+
429+ After creating the custom transport class, register it as a service in your
430+ application and :doc: `tag it </service_container/tags >` with the
431+ ``mailer.transport_factory `` tag.
432+
404433Creating & Sending Messages
405434---------------------------
406435
You can’t perform that action at this time.
0 commit comments