1
1
How to Work with Emails During Development
2
2
==========================================
3
3
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
4
+ When developing an application which sends email , you will often
5
+ not want to actually send the email to the specified recipient during
6
6
development. If you are using the ``SwiftmailerBundle `` with Symfony2, you
7
7
can easily achieve this through configuration settings without having to
8
8
make any changes to your application's code at all. There are two main
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
9
+ choices when it comes to handling email during development: (a) disabling the
10
+ sending of email altogether or (b) sending all email to a specific
11
11
address.
12
12
13
13
Disabling Sending
14
14
-----------------
15
15
16
- You can disable sending emails by setting the ``disable_delivery `` option
16
+ You can disable sending email by setting the ``disable_delivery `` option
17
17
to ``true ``. This is the default in the ``test `` environment in the Standard
18
- distribution. If you do this in the ``test `` specific config then emails
18
+ distribution. If you do this in the ``test `` specific config then email
19
19
will not be sent when you run tests, but will continue to be sent in the
20
20
``prod `` and ``dev `` environments:
21
21
@@ -47,12 +47,12 @@ will not be sent when you run tests, but will continue to be sent in the
47
47
));
48
48
49
49
If you'd also like to disable deliver in the ``dev `` environment, simply
50
- add this configuration to the ``config_dev.yml `` file.
50
+ add this same configuration to the ``config_dev.yml `` file.
51
51
52
52
Sending to a Specified Address
53
53
------------------------------
54
54
55
- You can also choose to have all emails sent to a specific address, instead
55
+ You can also choose to have all email sent to a specific address, instead
56
56
of the address actually specified when sending the message. This can be done
57
57
via the ``delivery_address `` option:
58
58
@@ -101,9 +101,8 @@ Now, suppose you're sending an email to ``recipient@example.com``.
101
101
}
102
102
103
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.
104
+ Swiftmailer will add an extra header to the email, ``X-Swift-To ``, containing
105
+ the replaced address, so you can still see who it would have been sent to.
107
106
108
107
.. note ::
109
108
@@ -116,11 +115,15 @@ sent to.
116
115
Viewing from the Web Debug Toolbar
117
116
----------------------------------
118
117
119
- You can view any emails sent by a page when you are in the `` dev `` environment
120
- using the Web Debug Toolbar. The email icon in the toolbar will show how
121
- many emails were sent. If you click it, a report showing the details of the
122
- emails will open .
118
+ You can view any email sent during a single response when you are in the
119
+ `` dev `` environment using the Web Debug Toolbar. The email icon in the toolbar
120
+ will show how many emails were sent. If you click it, a report will open
121
+ showing the details of the sent emails .
123
122
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.
123
+ If you're sending an email and then immediately redirecting to another page,
124
+ the web debug toolbar will not display an email icon or a report on the next
125
+ page.
126
+
127
+ Instead, you'll need to set the ``intercept_redirects `` option to ``true `` in
128
+ the ``config_dev.yml `` file, which will cause the redirect to stop and allow
129
+ you to open the report with details of the sent emails.
0 commit comments