Skip to content

Commit 349d506

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: [#14565] Minor formatting fixes Complete mailer integration
2 parents 8bc638d + ad317c3 commit 349d506

File tree

2 files changed

+171
-3
lines changed

2 files changed

+171
-3
lines changed

mailer.rst

+50
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,59 @@ over SMTP by configuring the DSN in your ``.env`` file (the ``user``,
2727
# .env
2828
MAILER_DSN=smtp://user:[email protected]:port
2929
30+
.. configuration-block::
31+
32+
.. code-block:: yaml
33+
34+
# config/packages/mailer.yaml
35+
framework:
36+
mailer:
37+
dsn: '%env(MAILER_DSN)%'
38+
39+
.. code-block:: xml
40+
41+
<!-- config/packages/mailer.xml -->
42+
<?xml version="1.0" encoding="UTF-8" ?>
43+
<container xmlns="http://symfony.com/schema/dic/services"
44+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
45+
xmlns:framework="http://symfony.com/schema/dic/symfony"
46+
xsi:schemaLocation="http://symfony.com/schema/dic/services
47+
https://symfony.com/schema/dic/services/services-1.0.xsd
48+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
49+
<framework:config>
50+
<framework:mailer dsn="%env(MAILER_DSN)%"/>
51+
</framework:config>
52+
</container>
53+
54+
.. code-block:: php
55+
56+
// config/packages/mailer.php
57+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
58+
return static function (ContainerConfigurator $containerConfigurator): void {
59+
$containerConfigurator->extension('framework', [
60+
'mailer' => [
61+
'dsn' => '%env(MAILER_DSN)%',
62+
]
63+
]);
64+
};
65+
3066
.. caution::
3167

3268
If you are migrating from Swiftmailer (and the Swiftmailer bundle), be
3369
warned that the DSN format is different.
3470

71+
Using Built-in Transports
72+
~~~~~~~~~~~~~~~~~~~~~~~~~
73+
74+
============ ======================================== ==============================
75+
DSN protocol Example Description
76+
============ ======================================== ==============================
77+
smtp ``smtp://user:[email protected]:25`` Mailer uses an SMTP server to
78+
send emails
79+
sendmail ``sendmail://default`` Mailer uses the local sendmail
80+
binary to send emails
81+
============ ======================================== ==============================
82+
3583
Using a 3rd Party Transport
3684
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3785

@@ -837,6 +885,8 @@ and it will select the appropriate certificate depending on the ``To`` option::
837885
$firstEncryptedEmail = $encrypter->encrypt($firstEmail);
838886
$secondEncryptedEmail = $encrypter->encrypt($secondEmail);
839887

888+
.. _multiple-email-transports:
889+
840890
Multiple Email Transports
841891
-------------------------
842892

reference/configuration/framework.rst

+121-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Configuration
9898
* `cafile`_
9999
* `capath`_
100100
* `ciphers`_
101-
* `headers`_
101+
* :ref:`headers <http-headers>`
102102
* `http_version`_
103103
* `local_cert`_
104104
* `local_pk`_
@@ -126,7 +126,7 @@ Configuration
126126
* `cafile`_
127127
* `capath`_
128128
* `ciphers`_
129-
* `headers`_
129+
* :ref:`headers <http-headers>`
130130
* `http_version`_
131131
* `local_cert`_
132132
* `local_pk`_
@@ -151,6 +151,17 @@ Configuration
151151

152152
* :ref:`name <reference-lock-resources-name>`
153153

154+
* `mailer`_
155+
156+
* :ref:`dsn <mailer-dsn>`
157+
* `transports`_
158+
* `envelope`_
159+
160+
* `sender`_
161+
* `recipients`_
162+
163+
* :ref:`headers <mailer-headers>`
164+
154165
* `php_errors`_
155166

156167
* `log`_
@@ -159,7 +170,7 @@ Configuration
159170
* `profiler`_
160171

161172
* `collect`_
162-
* `dsn`_
173+
* :ref:`dsn <profiler-dsn>`
163174
* :ref:`enabled <reference-profiler-enabled>`
164175
* `only_exceptions`_
165176
* `only_master_requests`_
@@ -835,6 +846,8 @@ ciphers
835846
A list of the names of the ciphers allowed for the SSL/TLS connections. They
836847
can be separated by colons, commas or spaces (e.g. ``'RC4-SHA:TLS13-AES-128-GCM-SHA256'``).
837848

849+
.. _http-headers:
850+
838851
headers
839852
.......
840853

@@ -1039,6 +1052,8 @@ only_master_requests
10391052
When this is set to ``true``, the profiler will only be enabled on the master
10401053
requests (and not on the subrequests).
10411054

1055+
.. _profiler-dsn:
1056+
10421057
dsn
10431058
...
10441059

@@ -2779,6 +2794,109 @@ Name of the lock you want to create.
27792794
decorates: lock.invoice.store
27802795
arguments: ['@.inner', 100, 50]
27812796
2797+
mailer
2798+
~~~~~~
2799+
2800+
.. versionadded:: 4.3
2801+
2802+
The ``mailer`` settings were introduced in Symfony 4.3.
2803+
2804+
.. _mailer-dsn:
2805+
2806+
dsn
2807+
...
2808+
2809+
**type**: ``string`` **default**: ``null``
2810+
2811+
The DSN used by the mailer. When several DSN may be used, use
2812+
``transports`` option (see below) instead.
2813+
2814+
transports
2815+
..........
2816+
2817+
**type**: ``array``
2818+
2819+
A :ref:`list of DSN <multiple-email-transports>` that can be used by the
2820+
mailer. A transport name is the key and the dsn is the value.
2821+
2822+
envelope
2823+
........
2824+
2825+
sender
2826+
""""""
2827+
2828+
**type**: ``string``
2829+
2830+
Sender used by the ``Mailer``. Keep in mind that this setting override a
2831+
sender set in the code.
2832+
2833+
recipients
2834+
""""""""""
2835+
2836+
**type**: ``array``
2837+
2838+
Recipients used by the ``Mailer``. Keep in mind that this setting override
2839+
recipients set in the code.
2840+
2841+
.. configuration-block::
2842+
2843+
.. code-block:: yaml
2844+
2845+
# config/packages/mailer.yaml
2846+
framework:
2847+
mailer:
2848+
dsn: 'smtp://localhost:25'
2849+
envelope:
2850+
2851+
2852+
.. code-block:: xml
2853+
2854+
<!-- config/packages/mailer.xml -->
2855+
<?xml version="1.0" encoding="UTF-8" ?>
2856+
<container xmlns="http://symfony.com/schema/dic/services"
2857+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2858+
xmlns:framework="http://symfony.com/schema/dic/symfony"
2859+
xsi:schemaLocation="http://symfony.com/schema/dic/services
2860+
https://symfony.com/schema/dic/services/services-1.0.xsd
2861+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
2862+
<framework:config>
2863+
<framework:mailer dsn="smtp://localhost:25">
2864+
<framework:envelope>
2865+
<framework:recipient>[email protected]</framework:recipient>
2866+
<framework:recipient>[email protected]</framework:recipient>
2867+
</framework:envelope>
2868+
</framework:mailer>
2869+
</framework:config>
2870+
</container>
2871+
2872+
.. code-block:: php
2873+
2874+
// config/packages/mailer.php
2875+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
2876+
return static function (ContainerConfigurator $containerConfigurator): void {
2877+
$containerConfigurator->extension('framework', [
2878+
'mailer' => [
2879+
'dsn' => 'smtp://localhost:25',
2880+
'envelope' => [
2881+
'recipients' => [
2882+
2883+
2884+
]
2885+
]
2886+
]
2887+
]);
2888+
};
2889+
2890+
.. _mailer-headers:
2891+
2892+
headers
2893+
.......
2894+
2895+
**type**: ``array``
2896+
2897+
Headers to add to emails. key (``name`` attribute in xml format)
2898+
is the header name and value the header value.
2899+
27822900
workflows
27832901
~~~~~~~~~
27842902

0 commit comments

Comments
 (0)