Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit72b69c1

Browse files
AlbertMorenoDEVjaviereguiluz
authored andcommitted
[Mailer] Add custom transport factories
1 parentd52bced commit72b69c1

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

‎mailer.rst‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,54 @@ Other Options
356356

357357
This option was introduced in Symfony 5.2.
358358

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`:
381+
382+
..configuration-block::
383+
384+
..code-block::yaml
385+
386+
# config/services.yaml
387+
mailer.transport_factory.custom:
388+
class:App\CustomTransportFactory
389+
parent:mailer.transport_factory.abstract
390+
tags:
391+
-{name: mailer.transport_factory}
392+
393+
..code-block::xml
394+
395+
<!-- config/services.xml-->
396+
<serviceid="mailer.transport_factory.custom"class="App\CustomTransportFactory"parent="mailer.transport_factory.abstract">
397+
<tagname="mailer.transport_factory"/>
398+
</service>
399+
400+
..code-block::php
401+
402+
// config/services.php
403+
$services->set('mailer.transport_factory.custom', App\CustomTransportFactory::class)
404+
->parent('mailer.transport_factory.abstract')
405+
->tag('mailer.transport_factory');
406+
359407
Creating & Sending Messages
360408
---------------------------
361409

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp