-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[swiftmailer] Document whitelist option to email redirect #4924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7da8094
22b625d
fe0b9d5
2c72cfb
e86739b
42a5bfd
f07d355
6c4a9aa
e09f3e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ can easily achieve this through configuration settings without having to | |
make any changes to your application's code at all. There are two main | ||
choices when it comes to handling email during development: (a) disabling the | ||
sending of email altogether or (b) sending all email to a specific | ||
address. | ||
address (with optional exceptions). | ||
|
||
Disabling Sending | ||
----------------- | ||
|
@@ -119,6 +119,67 @@ the replaced address, so you can still see who it would have been sent to. | |
These are ``X-Swift-Cc`` and ``X-Swift-Bcc`` for the ``CC`` and ``BCC`` | ||
addresses respectively. | ||
|
||
Sending to a Specified Address but with Exceptions | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Suppose you want to have all email redirected to a specific address, | ||
(like in the above scenario to ``[email protected]``). But then you may want | ||
email sent to some specific email addresses to go through after all, and | ||
not be redirected (even if it is in the dev environment). This can be done | ||
by adding the ``delivery_whitelist`` option: | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
|
||
# app/config/config_dev.yml | ||
swiftmailer: | ||
delivery_address: [email protected] | ||
delivery_whitelist: | ||
# all email addresses matching this regex will *not* be | ||
# redirected to [email protected] | ||
- "/@specialdomain.com$/" | ||
|
||
# all emails sent to [email protected] won't | ||
# be redirected to [email protected] too | ||
- "/^[email protected]$/" | ||
|
||
.. code-block:: xml | ||
|
||
<!-- app/config/config_dev.xml --> | ||
|
||
<?xml version="1.0" charset="UTF-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:swiftmailer="http://symfony.com/schema/dic/swiftmailer"> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should show a full XML config example here (I believe I've put an example in one of my comments in this PR) |
||
<swiftmailer:config delivery-address="[email protected]"> | ||
<!-- all email addresses matching this regex will *not* be redirected to [email protected] --> | ||
<swiftmailer:delivery-whitelist-pattern>/@specialdomain.com$/</swiftmailer:delivery-whitelist-pattern> | ||
|
||
<!-- all emails sent to [email protected] won't be redirected to [email protected] too --> | ||
<swiftmailer:delivery-whitelist-pattern>/^[email protected]$/</swiftmailer:delivery-whitelist-pattern> | ||
</swiftmailer:config> | ||
|
||
.. code-block:: php | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a missing blank line above this line |
||
|
||
// app/config/config_dev.php | ||
$container->loadFromExtension('swiftmailer', array( | ||
'delivery_address' => "[email protected]", | ||
'delivery_whitelist' => array( | ||
// all email addresses matching this regex will *not* be | ||
// redirected to [email protected] | ||
'/@specialdomain.com$/', | ||
|
||
// all emails sent to [email protected] won't be | ||
// redirected to [email protected] too | ||
'/^[email protected]$/', | ||
), | ||
)); | ||
|
||
In the above example all email messages will be redirected to ``[email protected]``, | ||
except messages sent to the ``[email protected]`` address or to any email | ||
address belonging to the domain ``specialdomain.com``, which will be delivered as normal. | ||
|
||
Viewing from the Web Debug Toolbar | ||
---------------------------------- | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know which is the common practice in the Symfony docs (maybe @wouterj and @xabbuh can help us with this) but it's strange to add explanation comments in the PHP format but not include them in the XML and PHP formats. We have two solutions:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually add the comments to all formats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have now repeated the comments for all formats.