@@ -18,9 +18,9 @@ integration, CSS inlining, file attachments and a lot more. Get them installed w
1818Transport 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
3535Using 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================== =============================================
4242Service Install with
@@ -50,7 +50,7 @@ SendGrid ``composer require symfony/sendgrid-mailer``
5050================== =============================================
5151
5252Each 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
5454use 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
7573Each provider has different environment variables that the Mailer uses to
7674configure the *actual * protocol, address and authentication for delivery. Some
@@ -93,8 +91,8 @@ Creating & Sending Messages
9391---------------------------
9492
9593To 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
132130Email Addresses
133131~~~~~~~~~~~~~~~
@@ -775,20 +773,15 @@ Always Send to the same Address
775773~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
776774
777775Instead of disabling delivery entirely, you might want to *always * send emails to
778- a specific address, instead of the *real * address. To do that, you can take
779- advantage of the ``EnvelopeListener `` and register it *only * for the ``dev ``
780- environment:
776+ a specific address, instead of the *real * address:
781777
782778.. code-block :: yaml
783779
784- # config/services_dev.yaml
785- services :
786- mailer.dev.set_recipients :
787- class : Symfony\Component\Mailer\EventListener\EnvelopeListener
788- tags : ['kernel.event_subscriber']
789- arguments :
790- $sender : null
791- $recipients : ['youremail@example.com']
780+ # config/packages/dev/mailer.yaml
781+ framework :
782+ mailer :
783+ envelope :
784+ recipients : ['youremail@example.com']
792785
793786 .. _`download the foundation-emails.css file` : https://github.com/foundation/foundation-emails/blob/develop/dist/foundation-emails.css
794787.. _`league/html-to-markdown` : https://github.com/thephpleague/html-to-markdown
0 commit comments