@@ -20,9 +20,9 @@ integration, CSS inlining, file attachments and a lot more. Get them installed w
20
20
Transport Setup
21
21
---------------
22
22
23
- Emails are delivered via a "transport". And without installing anything else , you
24
- can deliver emails over ``smtp `` by configuring your ``.env `` file (the
25
- ``user ``, `` pass `` and `` port `` parameters are optional):
23
+ Emails are delivered via a "transport". Out of the box , you can deliver emails
24
+ over ``SMTP `` by configuring your ``.env `` file (the `` user ``, `` pass `` and
25
+ ``port `` parameters are optional):
26
26
27
27
.. code-block :: bash
28
28
@@ -37,8 +37,8 @@ can deliver emails over ``smtp`` by configuring your ``.env`` file (the
37
37
Using a 3rd Party Transport
38
38
~~~~~~~~~~~~~~~~~~~~~~~~~~~
39
39
40
- But an easier option is to send emails via a 3rd party provider. Mailer supports
41
- several - install whichever you want:
40
+ Instead of using your own SMTP server, you can send emails via a 3rd party
41
+ provider. Mailer supports several - install whichever you want:
42
42
43
43
================== =============================================
44
44
Service Install with
@@ -52,7 +52,7 @@ SendGrid ``composer require symfony/sendgrid-mailer``
52
52
================== =============================================
53
53
54
54
Each library includes a :ref: `Symfony Flex recipe <symfony-flex >` that will add
55
- example configuration to your ``.env `` file. For example, suppose you want to
55
+ a configuration example to your ``.env `` file. For example, suppose you want to
56
56
use SendGrid. First, install it:
57
57
58
58
.. code-block :: terminal
@@ -66,13 +66,11 @@ You'll now have a new line in your ``.env`` file that you can uncomment:
66
66
# .env
67
67
MAILER_DSN=sendgrid://KEY@default
68
68
69
- The ``MAILER_DSN `` isn't a *real * address: it's a simple format that offloads
70
- most of the configuration work to mailer. The ``sendgrid `` scheme activates the
71
- SendGrid provider that you just installed, which knows all about how to deliver
72
- messages to SendGrid.
73
-
74
- The *only * part you need to change is to replace ``KEY `` in the ``MAILER_DSN `` (in
75
- ``.env `` or ``.env.local ``).
69
+ The ``MAILER_DSN `` isn't a *real * address: it's a convenient format that
70
+ offloads most of the configuration work to mailer. The ``sendgrid `` scheme
71
+ activates the SendGrid provider that you just installed, which knows all about
72
+ how to deliver messages via SendGrid. The *only * part you need to change is the
73
+ ``KEY `` placeholder.
76
74
77
75
Each provider has different environment variables that the Mailer uses to
78
76
configure the *actual * protocol, address and authentication for delivery. Some
@@ -95,8 +93,8 @@ Creating & Sending Messages
95
93
---------------------------
96
94
97
95
To send an email, autowire the mailer using
98
- :class: `Symfony\\ Component\\ Mailer\\ MailerInterface ` (service id `` mailer.mailer ``)
99
- and create an :class: `Symfony\\ Component\\ Mime\\ Email ` object::
96
+ :class: `Symfony\\ Component\\ Mailer\\ MailerInterface ` and create an
97
+ :class: `Symfony\\ Component\\ Mime\\ Email ` object::
100
98
101
99
// src/Controller/MailerController.php
102
100
namespace App\Controller;
@@ -129,7 +127,7 @@ and create an :class:`Symfony\\Component\\Mime\\Email` object::
129
127
}
130
128
}
131
129
132
- That's it! The message will be sent via whatever transport you configured.
130
+ That's it! The message will be sent via the transport you configured.
133
131
134
132
Email Addresses
135
133
~~~~~~~~~~~~~~~
@@ -793,20 +791,15 @@ Always Send to the same Address
793
791
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
794
792
795
793
Instead of disabling delivery entirely, you might want to *always * send emails to
796
- a specific address, instead of the *real * address. To do that, you can take
797
- advantage of the ``EnvelopeListener `` and register it *only * for the ``dev ``
798
- environment:
794
+ a specific address, instead of the *real * address:
799
795
800
796
.. code-block :: yaml
801
797
802
- # config/services_dev.yaml
803
- services :
804
- mailer.dev.set_recipients :
805
- class : Symfony\Component\Mailer\EventListener\EnvelopeListener
806
- tags : ['kernel.event_subscriber']
807
- arguments :
808
- $sender : null
809
- $recipients : ['youremail@example.com']
798
+ # config/packages/dev/mailer.yaml
799
+ framework :
800
+ mailer :
801
+ envelope :
802
+ recipients : ['youremail@example.com']
810
803
811
804
.. _`download the foundation-emails.css file` : https://github.com/foundation/foundation-emails/blob/develop/dist/foundation-emails.css
812
805
.. _`league/html-to-markdown` : https://github.com/thephpleague/html-to-markdown
0 commit comments