Skip to content

Commit 0c615e7

Browse files
committed
Merge branch '5.0' into 5.1
* 5.0: Mailer tweaks Update factories.rst
2 parents 0c5594a + 034b8d1 commit 0c615e7

File tree

2 files changed

+20
-28
lines changed

2 files changed

+20
-28
lines changed

mailer.rst

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ integration, CSS inlining, file attachments and a lot more. Get them installed w
1818
Transport Setup
1919
---------------
2020

21-
Emails are delivered via a "transport". And without installing anything else, you
22-
can deliver emails over ``smtp`` by configuring your ``.env`` file (the
23-
``user``, ``pass`` and ``port`` parameters are optional):
21+
Emails are delivered via a "transport". Out of the box, you can deliver emails
22+
over ``SMTP`` by configuring your ``.env`` file (the ``user``, ``pass`` and
23+
``port`` parameters are optional):
2424

2525
.. code-block:: bash
2626
@@ -35,8 +35,8 @@ can deliver emails over ``smtp`` by configuring your ``.env`` file (the
3535
Using a 3rd Party Transport
3636
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3737

38-
But an easier option is to send emails via a 3rd party provider. Mailer supports
39-
several - install whichever you want:
38+
Instead of using your own SMTP server, you can send emails via a 3rd party
39+
provider. Mailer supports several - install whichever you want:
4040

4141
================== =============================================
4242
Service Install with
@@ -50,7 +50,7 @@ SendGrid ``composer require symfony/sendgrid-mailer``
5050
================== =============================================
5151

5252
Each library includes a :ref:`Symfony Flex recipe <symfony-flex>` that will add
53-
example configuration to your ``.env`` file. For example, suppose you want to
53+
a configuration example to your ``.env`` file. For example, suppose you want to
5454
use SendGrid. First, install it:
5555

5656
.. code-block:: terminal
@@ -64,13 +64,11 @@ You'll now have a new line in your ``.env`` file that you can uncomment:
6464
# .env
6565
MAILER_DSN=sendgrid://KEY@default
6666
67-
The ``MAILER_DSN`` isn't a *real* address: it's a simple format that offloads
68-
most of the configuration work to mailer. The ``sendgrid`` scheme activates the
69-
SendGrid provider that you just installed, which knows all about how to deliver
70-
messages to SendGrid.
71-
72-
The *only* part you need to change is to replace ``KEY`` in the ``MAILER_DSN`` (in
73-
``.env`` or ``.env.local``).
67+
The ``MAILER_DSN`` isn't a *real* address: it's a convenient format that
68+
offloads most of the configuration work to mailer. The ``sendgrid`` scheme
69+
activates the SendGrid provider that you just installed, which knows all about
70+
how to deliver messages via SendGrid. The *only* part you need to change is the
71+
``KEY`` placeholder.
7472

7573
Each provider has different environment variables that the Mailer uses to
7674
configure the *actual* protocol, address and authentication for delivery. Some
@@ -93,8 +91,8 @@ Creating & Sending Messages
9391
---------------------------
9492

9593
To send an email, autowire the mailer using
96-
:class:`Symfony\\Component\\Mailer\\MailerInterface` (service id ``mailer.mailer``)
97-
and create an :class:`Symfony\\Component\\Mime\\Email` object::
94+
:class:`Symfony\\Component\\Mailer\\MailerInterface` and create an
95+
:class:`Symfony\\Component\\Mime\\Email` object::
9896

9997
// src/Controller/MailerController.php
10098
namespace App\Controller;
@@ -127,7 +125,7 @@ and create an :class:`Symfony\\Component\\Mime\\Email` object::
127125
}
128126
}
129127

130-
That's it! The message will be sent via whatever transport you configured.
128+
That's it! The message will be sent via the transport you configured.
131129

132130
Email Addresses
133131
~~~~~~~~~~~~~~~
@@ -811,20 +809,15 @@ Always Send to the same Address
811809
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
812810

813811
Instead of disabling delivery entirely, you might want to *always* send emails to
814-
a specific address, instead of the *real* address. To do that, you can take
815-
advantage of the ``EnvelopeListener`` and register it *only* for the ``dev``
816-
environment:
812+
a specific address, instead of the *real* address:
817813

818814
.. code-block:: yaml
819815
820-
# config/services_dev.yaml
821-
services:
822-
mailer.dev.set_recipients:
823-
class: Symfony\Component\Mailer\EventListener\EnvelopeListener
824-
tags: ['kernel.event_subscriber']
825-
arguments:
826-
$sender: null
827-
$recipients: ['youremail@example.com']
816+
# config/packages/dev/mailer.yaml
817+
framework:
818+
mailer:
819+
envelope:
820+
recipients: ['youremail@example.com']
828821
829822
.. _`download the foundation-emails.css file`: https://github.com/foundation/foundation-emails/blob/develop/dist/foundation-emails.css
830823
.. _`league/html-to-markdown`: https://github.com/thephpleague/html-to-markdown

service_container/factories.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ method name, just as routes can reference
229229
$services = $configurator->services();
230230
231231
$services->set(NewsletterManager::class)
232-
->args([service('templating')])
233232
->factory(service(NewsletterManagerFactory::class));
234233
};
235234

0 commit comments

Comments
 (0)