File tree 1 file changed +29
-0
lines changed 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -397,6 +397,35 @@ Other Options
397
397
398
398
The ``max_per_second `` option was introduced in Symfony 6.2.
399
399
400
+ Custom Transport Factories
401
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
402
+
403
+ If you want to support your own custom DSN (``acme://... ``), you can create a
404
+ custom transport factory. To do so, create a class that implements
405
+ :class: `Symfony\\ Component\\ Mailer\\ Transport\\ TransportFactoryInterface ` or, if
406
+ you prefer, extend the :class: `Symfony\\ Component\\ Mailer\\ Transport\\ AbstractTransportFactory `
407
+ class to save some boilerplate code::
408
+
409
+ // src/Mailer/AcmeTransportFactory.php
410
+ final class AcmeTransportFactory extends AbstractTransportFactory
411
+ {
412
+ public function create(Dsn $dsn): TransportInterface
413
+ {
414
+ // parse the given DSN, extract data/credentials from it
415
+ // and then, create and return the transport
416
+ }
417
+
418
+ protected function getSupportedSchemes(): array
419
+ {
420
+ // this supports DSN starting with `acme://`
421
+ return ['acme'];
422
+ }
423
+ }
424
+
425
+ After creating the custom transport class, register it as a service in your
426
+ application and :doc: `tag it </service_container/tags >` with the
427
+ ``mailer.transport_factory `` tag.
428
+
400
429
Creating & Sending Messages
401
430
---------------------------
402
431
You can’t perform that action at this time.
0 commit comments