Skip to content

Commit 6f64fdb

Browse files
TerjeBrweaverryan
authored andcommitted
Document whitelist option to email redirect
The redirectPlugin in switfmailer allows you to specify a white list of regex's that are still sent to when disabling sending. Added in PR switfmailer/SwiftmailerBundle#19
1 parent 9fab10b commit 6f64fdb

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

cookbook/email/dev_environment.rst

+46-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ can easily achieve this through configuration settings without having to
1111
make any changes to your application's code at all. There are two main
1212
choices when it comes to handling email during development: (a) disabling the
1313
sending of email altogether or (b) sending all email to a specific
14-
address.
14+
address (with optional exceptions).
1515

1616
Disabling Sending
1717
-----------------
@@ -119,6 +119,51 @@ the replaced address, so you can still see who it would have been sent to.
119119
These are ``X-Swift-Cc`` and ``X-Swift-Bcc`` for the ``CC`` and ``BCC``
120120
addresses respectively.
121121

122+
Sending to a Specified Address, but with exceptions
123+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124+
125+
Suppose you want to have all email sent to a specific address, instead
126+
of the address actually specified when sending the message (like in the above scenario),
127+
but you want certain email addresses not to be redirected in this way.
128+
This can be done by adding the ``delivery_whitelist`` option:
129+
130+
.. configuration-block::
131+
132+
.. code-block:: yaml
133+
134+
# app/config/config_dev.yml
135+
swiftmailer:
136+
delivery_address: dev@example.com
137+
delivery_whitelist:
138+
- "/@mydomain.com$/"
139+
- "/^admin@specialdomain.com$/"
140+
141+
.. code-block:: xml
142+
143+
<!-- app/config/config_dev.xml -->
144+
145+
<!--
146+
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"
147+
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd
148+
-->
149+
150+
<swiftmailer:config delivery-address="dev@example.com" />
151+
<swiftmailer:delivery-whitelist>/@mydomain.com$/</swiftmailer:delivery-whitelist>
152+
<swiftmailer:delivery-whitelist>/^admin@specialdomain.com$/</swiftmailer:delivery-whitelist>
153+
.. code-block:: php
154+
155+
// app/config/config_dev.php
156+
$container->loadFromExtension('swiftmailer', array(
157+
'delivery_address' => "dev@example.com",
158+
'delivery_whitelist' => array(
159+
'/@mydomain.com$/',
160+
'/^admin@specialdomain.com$/'
161+
),
162+
));
163+
164+
In the above example all mail will be redirected to ``dev@example.com``, exept that mail to the single
165+
address ``admin@specialdomain.com`` and all mail to the domain ``mydomain.com`` will be delivered as normal.
166+
122167
Viewing from the Web Debug Toolbar
123168
----------------------------------
124169

0 commit comments

Comments
 (0)