Skip to content

Commit 2e254df

Browse files
committed
[cookbook] Proofreading the new emails in dev environment post
1 parent 1168f42 commit 2e254df

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

cookbook/email/dev_environment.rst

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
How to Work with Emails During Development
22
==========================================
33

4-
When you are creating an application which sends emails you will often
5-
not want to actually send the emails to the specified recipient during
6-
development. If you are using the ``SwiftmailerBundle`` with Symfony2 you
4+
When you are creating an application which sends emails, you will often
5+
not want to actually send the emails to the specified recipient while
6+
development. If you are using the ``SwiftmailerBundle`` with Symfony2, you
77
can easily achieve this through configuration settings without having to
88
make any changes to your application's code at all. There are two main
9-
choices to disable sending emails altogether and to send them all to a
10-
specified address.
9+
choices when it comes to handling emails during development: (a) disabling the
10+
sending of emails altogether or (b) sending all the emails to a specified
11+
address.
1112

1213
Disabling Sending
1314
-----------------
1415

1516
You can disable sending emails by setting the ``disable_delivery`` option
1617
to ``true``. This is the default in the ``test`` environment in the Standard
1718
distribution. If you do this in the ``test`` specific config then emails
18-
will not be sent when you run tets and will continue to be sent in the
19+
will not be sent when you run tests, but will continue to be sent in the
1920
``prod`` and ``dev`` environments:
2021

2122
.. configuration-block::
@@ -45,13 +46,15 @@ will not be sent when you run tets and will continue to be sent in the
4546
'disable_delivery' => "true",
4647
));
4748
49+
If you'd also like to disable deliver in the ``dev`` environment, simply
50+
add this configuration to the ``config_dev.yml`` file.
4851

49-
Sending to a Specifed Address
50-
-----------------------------
52+
Sending to a Specified Address
53+
------------------------------
5154

52-
You can also choose to have all emails sent to an address set in the config,
53-
instead of the address they are set to be sent to, with the ``delivery_address``
54-
option:
55+
You can also choose to have all emails sent to a specific address, instead
56+
of the address actually specified when sending the message. This can be done
57+
via the ``delivery_address`` option:
5558

5659
.. configuration-block::
5760

@@ -80,7 +83,7 @@ option:
8083
'delivery_address' => "dev@example.com",
8184
));
8285
83-
So if an email is sent from your app:
86+
Now, suppose you're sending an email to ``recipient@example.com``.
8487

8588
.. code-block:: php
8689
@@ -97,15 +100,15 @@ So if an email is sent from your app:
97100
return $this->render(...);
98101
}
99102
100-
Then instead of being sent to ``recipient@example.com`` it will be sent
101-
to ``dev@example.com``. Swiftmailer will add an extra header to the email,
102-
``X-Swift-To`` containing the replaced address, so you will still be able
103-
to see who it would have been sent to.
103+
In the ``dev`` environment, the email will instead be sent to ``dev@example.com``.
104+
Swiftmailer will add an extra header to the email, ``X-Swift-To`` containing
105+
the replaced address, so you will still be able to see who it would have been
106+
sent to.
104107

105108
.. note::
106109

107-
As well as ``to`` addresses, this will also stop the email being sent
108-
to any ``CC`` and ``BCC`` addresses set for it. Swiftmailer will add
110+
In addition to the ``to`` addresses, this will also stop the email being
111+
sent to any ``CC`` and ``BCC`` addresses set for it. Swiftmailer will add
109112
additional headers to the email with the overridden addresses in them.
110113
These are ``X-Swift-Cc`` and ``X-Swift-Bcc`` for the ``CC`` and ``BCC``
111114
addresses respectively.
@@ -115,5 +118,9 @@ Viewing from the Web Debug Toolbar
115118

116119
You can view any emails sent by a page when you are in the ``dev`` environment
117120
using the Web Debug Toolbar. The email icon in the toolbar will show how
118-
many emails were sent. If you click it a report showing the details of the
121+
many emails were sent. If you click, it a report showing the details of the
119122
emails will open.
123+
124+
If you're sending an email and then redirecting immediately after, you'll
125+
need to set the ``intercept_redirects`` option to ``true`` in the ``config_dev.yml``
126+
file so that you can see the email in the web debug toolbar before being redirected.

cookbook/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Cookbook
4343

4444
email
4545
gmail
46+
email/dev_environment
4647
email/spool
4748

4849
testing/http_authentication

cookbook/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
* :doc:`/cookbook/email`
5656
* :doc:`/cookbook/gmail`
57+
* :doc:`/cookbook/email/dev_environment`
5758
* :doc:`/cookbook/email/spool`
5859

5960
* **Testing**

0 commit comments

Comments
 (0)