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