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

[Mailer] Add custom transport factories#16373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
javiereguiluz merged 1 commit intosymfony:5.4fromAlbertMorenoDEV:4.4
Jan 18, 2024
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletionsmailer.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -356,6 +356,54 @@ Other Options

This option was introduced in Symfony 5.2.

Custom Transport Factories
~~~~~~~~~~~~~~~~~~~~~~~~~~

There is a way to easily create your own custom transport factory in case you need to do something special creating the actual transport.

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::


final class CustomTransportFactory extends AbstractTransportFactory
{
public function create(Dsn $dsn): TransportInterface
{
// create and return the transport
}

protected function getSupportedSchemes(): array
{
return ['custom_schema'];
}
}

Finally, declare the new factory in setting tag the tag `mailer.transport_factory`:

.. configuration-block::

.. code-block:: yaml

# config/services.yaml
mailer.transport_factory.custom:
class: App\CustomTransportFactory
parent: mailer.transport_factory.abstract
tags:
- {name: mailer.transport_factory}

.. code-block:: xml

<!-- config/services.xml -->
<service id="mailer.transport_factory.custom" class="App\CustomTransportFactory" parent="mailer.transport_factory.abstract">
<tag name="mailer.transport_factory"/>
</service>

.. code-block:: php

// config/services.php
$services->set('mailer.transport_factory.custom', App\CustomTransportFactory::class)
->parent('mailer.transport_factory.abstract')
->tag('mailer.transport_factory');

Creating & Sending Messages
---------------------------

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp