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
minor #16373 [Mailer] Add custom transport factories (AlbertMorenoDEV)
This PR was submitted for the 4.4 branch but it was squashed and merged into the 5.4 branch instead.
Discussion
----------
[Mailer] Add custom transport factories
This might be useful for very custom use cases where we need to extract some data or do something before being able to create the actual transport.
The feature apparently was added here: symfony/symfony#31946
Commits
-------
72b69c1 [Mailer] Add custom transport factories
Copy file name to clipboardExpand all lines: mailer.rst
+48Lines changed: 48 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -356,6 +356,54 @@ Other Options
356
356
357
357
This option was introduced in Symfony 5.2.
358
358
359
+
Custom Transport Factories
360
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
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
368
+
{
369
+
public function create(Dsn $dsn): TransportInterface
370
+
{
371
+
// create and return the transport
372
+
}
373
+
374
+
protected function getSupportedSchemes(): array
375
+
{
376
+
return ['custom_schema'];
377
+
}
378
+
}
379
+
380
+
Finally, declare the new factory in setting tag the tag `mailer.transport_factory`:
0 commit comments