Skip to content

Commit f662683

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: Removed 4.3 versionadded directive [#14565] Minor formatting fixes Complete mailer integration
2 parents 1655638 + 453714f commit f662683

File tree

2 files changed

+167
-3
lines changed

2 files changed

+167
-3
lines changed

mailer.rst

Lines changed: 50 additions & 0 deletions
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:pass@smtp.example.com: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:pass@smtp.example.com: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

@@ -902,6 +950,8 @@ and it will select the appropriate certificate depending on the ``To`` option::
902950
$firstEncryptedEmail = $encrypter->encrypt($firstEmail);
903951
$secondEncryptedEmail = $encrypter->encrypt($secondEmail);
904952

953+
.. _multiple-email-transports:
954+
905955
Multiple Email Transports
906956
-------------------------
907957

reference/configuration/framework.rst

Lines changed: 117 additions & 3 deletions
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`_
@@ -174,6 +174,17 @@ Configuration
174174

175175
* :ref:`name <reference-lock-resources-name>`
176176

177+
* `mailer`_
178+
179+
* :ref:`dsn <mailer-dsn>`
180+
* `transports`_
181+
* `envelope`_
182+
183+
* `sender`_
184+
* `recipients`_
185+
186+
* :ref:`headers <mailer-headers>`
187+
177188
* `php_errors`_
178189

179190
* `log`_
@@ -182,7 +193,7 @@ Configuration
182193
* `profiler`_
183194

184195
* `collect`_
185-
* `dsn`_
196+
* :ref:`dsn <profiler-dsn>`
186197
* :ref:`enabled <reference-profiler-enabled>`
187198
* `only_exceptions`_
188199
* `only_master_requests`_
@@ -915,6 +926,8 @@ enabled
915926
Whether to enable the support for retry failed HTTP request or not.
916927
This setting is automatically set to true when one of the child settings is configured.
917928

929+
.. _http-headers:
930+
918931
headers
919932
.......
920933

@@ -1196,6 +1209,8 @@ only_master_requests
11961209
When this is set to ``true``, the profiler will only be enabled on the master
11971210
requests (and not on the subrequests).
11981211

1212+
.. _profiler-dsn:
1213+
11991214
dsn
12001215
...
12011216

@@ -2973,6 +2988,105 @@ Name of the lock you want to create.
29732988
decorates: lock.invoice.store
29742989
arguments: ['@.inner', 100, 50]
29752990
2991+
mailer
2992+
~~~~~~
2993+
2994+
.. _mailer-dsn:
2995+
2996+
dsn
2997+
...
2998+
2999+
**type**: ``string`` **default**: ``null``
3000+
3001+
The DSN used by the mailer. When several DSN may be used, use
3002+
``transports`` option (see below) instead.
3003+
3004+
transports
3005+
..........
3006+
3007+
**type**: ``array``
3008+
3009+
A :ref:`list of DSN <multiple-email-transports>` that can be used by the
3010+
mailer. A transport name is the key and the dsn is the value.
3011+
3012+
envelope
3013+
........
3014+
3015+
sender
3016+
""""""
3017+
3018+
**type**: ``string``
3019+
3020+
Sender used by the ``Mailer``. Keep in mind that this setting override a
3021+
sender set in the code.
3022+
3023+
recipients
3024+
""""""""""
3025+
3026+
**type**: ``array``
3027+
3028+
Recipients used by the ``Mailer``. Keep in mind that this setting override
3029+
recipients set in the code.
3030+
3031+
.. configuration-block::
3032+
3033+
.. code-block:: yaml
3034+
3035+
# config/packages/mailer.yaml
3036+
framework:
3037+
mailer:
3038+
dsn: 'smtp://localhost:25'
3039+
envelope:
3040+
recipients: ['admin@symfony.com', 'lead@symfony.com']
3041+
3042+
.. code-block:: xml
3043+
3044+
<!-- config/packages/mailer.xml -->
3045+
<?xml version="1.0" encoding="UTF-8" ?>
3046+
<container xmlns="http://symfony.com/schema/dic/services"
3047+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3048+
xmlns:framework="http://symfony.com/schema/dic/symfony"
3049+
xsi:schemaLocation="http://symfony.com/schema/dic/services
3050+
https://symfony.com/schema/dic/services/services-1.0.xsd
3051+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
3052+
<framework:config>
3053+
<framework:mailer dsn="smtp://localhost:25">
3054+
<framework:envelope>
3055+
<framework:recipient>admin@symfony.com</framework:recipient>
3056+
<framework:recipient>lead@symfony.com</framework:recipient>
3057+
</framework:envelope>
3058+
</framework:mailer>
3059+
</framework:config>
3060+
</container>
3061+
3062+
.. code-block:: php
3063+
3064+
// config/packages/mailer.php
3065+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
3066+
return static function (ContainerConfigurator $containerConfigurator): void {
3067+
$containerConfigurator->extension('framework', [
3068+
'mailer' => [
3069+
'dsn' => 'smtp://localhost:25',
3070+
'envelope' => [
3071+
'recipients' => [
3072+
'admin@symfony.com',
3073+
'lead@symfony.com',
3074+
]
3075+
]
3076+
]
3077+
]);
3078+
};
3079+
3080+
.. _mailer-headers:
3081+
3082+
headers
3083+
.......
3084+
3085+
**type**: ``array``
3086+
3087+
Headers to add to emails. key (``name`` attribute in xml format)
3088+
is the header name and value the header value.
3089+
29763090
workflows
29773091
~~~~~~~~~
29783092

0 commit comments

Comments
 (0)