From 7da809423fae013b2581357e9ae3e09758a6bc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Mon, 26 Jan 2015 14:57:29 +0000 Subject: [PATCH 1/9] 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 --- cookbook/email/dev_environment.rst | 47 +++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/cookbook/email/dev_environment.rst b/cookbook/email/dev_environment.rst index 65a5a64524e..ab2c8dc2d10 100644 --- a/cookbook/email/dev_environment.rst +++ b/cookbook/email/dev_environment.rst @@ -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,51 @@ 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 sent to a specific address, instead +of the address actually specified when sending the message (like in the above scenario), +but you want certain email addresses not to be redirected in this way. +This can be done by adding the ``delivery_whitelist`` option: + +.. configuration-block:: + + .. code-block:: yaml + + # app/config/config_dev.yml + swiftmailer: + delivery_address: dev@example.com + delivery_whitelist: + - "/@mydomain.com$/" + - "/^admin@specialdomain.com$/" + + .. code-block:: xml + + + + + + + /@mydomain.com$/ + /^admin@specialdomain.com$/ + .. code-block:: php + + // app/config/config_dev.php + $container->loadFromExtension('swiftmailer', array( + 'delivery_address' => "dev@example.com", + 'delivery_whitelist' => array( + '/@mydomain.com$/', + '/^admin@specialdomain.com$/' + ), + )); + +In the above example all mail will be redirected to ``dev@example.com``, exept that mail to the single +address ``admin@specialdomain.com`` and all mail to the domain ``mydomain.com`` will be delivered as normal. + Viewing from the Web Debug Toolbar ---------------------------------- From 22b625d925e46bea905cf8211b5e6d6acae5ff0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Mon, 26 Jan 2015 15:15:59 +0000 Subject: [PATCH 2/9] fixed typo in "except" --- cookbook/email/dev_environment.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/email/dev_environment.rst b/cookbook/email/dev_environment.rst index ab2c8dc2d10..f50d3ed2cf9 100644 --- a/cookbook/email/dev_environment.rst +++ b/cookbook/email/dev_environment.rst @@ -161,7 +161,7 @@ This can be done by adding the ``delivery_whitelist`` option: ), )); -In the above example all mail will be redirected to ``dev@example.com``, exept that mail to the single +In the above example all mail will be redirected to ``dev@example.com``, except that mail to the single address ``admin@specialdomain.com`` and all mail to the domain ``mydomain.com`` will be delivered as normal. Viewing from the Web Debug Toolbar From fe0b9d59d888bbe90943a3335f46e635456254a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Sat, 31 Jan 2015 15:42:03 +0000 Subject: [PATCH 3/9] Added improvments from @WouterJ --- cookbook/email/dev_environment.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cookbook/email/dev_environment.rst b/cookbook/email/dev_environment.rst index f50d3ed2cf9..5fc6f9573f4 100644 --- a/cookbook/email/dev_environment.rst +++ b/cookbook/email/dev_environment.rst @@ -122,9 +122,10 @@ the replaced address, so you can still see who it would have been sent to. Sending to a Specified Address, but with exceptions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Suppose you want to have all email sent to a specific address, instead -of the address actually specified when sending the message (like in the above scenario), -but you want certain email addresses not to be redirected in this way. +Suppose you normally in your dev environment want to have all email redirected to a specific address, +(like in the above scenario to ``dev@example,com``). +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:: @@ -135,7 +136,12 @@ This can be done by adding the ``delivery_whitelist`` option: swiftmailer: delivery_address: dev@example.com delivery_whitelist: + # all email addresses matching this regex will *not* be + # redirected to dev@example.com - "/@mydomain.com$/" + + # all emails sent to admin@specialdomain.com won't + # be redirected to dev@example.com too - "/^admin@specialdomain.com$/" .. code-block:: xml From 2c72cfb1567f4c7a499150285d73bca5f05b34b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Sun, 15 Feb 2015 17:24:29 +0000 Subject: [PATCH 4/9] Changed line-breaks in text --- cookbook/email/dev_environment.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cookbook/email/dev_environment.rst b/cookbook/email/dev_environment.rst index 5fc6f9573f4..27d1cf19d30 100644 --- a/cookbook/email/dev_environment.rst +++ b/cookbook/email/dev_environment.rst @@ -122,10 +122,10 @@ the replaced address, so you can still see who it would have been sent to. Sending to a Specified Address, but with exceptions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Suppose you normally in your dev environment want to have all email redirected to a specific address, -(like in the above scenario to ``dev@example,com``). -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). +Suppose you normally in your dev environment want to have all email redirected +to a specific address, (like in the above scenario to ``dev@example,com``). +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:: @@ -167,8 +167,9 @@ This can be done by adding the ``delivery_whitelist`` option: ), )); -In the above example all mail will be redirected to ``dev@example.com``, except that mail to the single -address ``admin@specialdomain.com`` and all mail to the domain ``mydomain.com`` will be delivered as normal. +In the above example all mail will be redirected to ``dev@example.com``, +except that mail to the single address ``admin@specialdomain.com`` and all +mail to the domain ``mydomain.com`` will be delivered as normal. Viewing from the Web Debug Toolbar ---------------------------------- From e86739b6b451293a2acc4c92d845224d2a4cc6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Mon, 16 Feb 2015 13:17:02 +0000 Subject: [PATCH 5/9] Changes recommended by @javierguiluz --- cookbook/email/dev_environment.rst | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cookbook/email/dev_environment.rst b/cookbook/email/dev_environment.rst index 27d1cf19d30..9b55e38e914 100644 --- a/cookbook/email/dev_environment.rst +++ b/cookbook/email/dev_environment.rst @@ -119,11 +119,11 @@ 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 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Sending to a Specified Address but with Exceptions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppose you normally in your dev environment want to have all email redirected -to a specific address, (like in the above scenario to ``dev@example,com``). +to a specific address, (like in the above scenario to ``dev@example.com``). 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: @@ -154,22 +154,30 @@ This can be done by adding the ``delivery_whitelist`` option: --> + /@mydomain.com$/ + /^admin@specialdomain.com$/ + .. code-block:: php // app/config/config_dev.php $container->loadFromExtension('swiftmailer', array( 'delivery_address' => "dev@example.com", 'delivery_whitelist' => array( + // all email addresses matching this regex will *not* be + // redirected to dev@example.com '/@mydomain.com$/', + + // all emails sent to admin@specialdomain.com won't be + // redirected to dev@example.com too '/^admin@specialdomain.com$/' ), )); -In the above example all mail will be redirected to ``dev@example.com``, -except that mail to the single address ``admin@specialdomain.com`` and all -mail to the domain ``mydomain.com`` will be delivered as normal. +In the above example all email messages will be redirected to ``dev@example.com``, +except messages sent to the ``admin@specialdomain.com`` address or to any email +address belonging to the domain ``mydomain.com``, which will be delivered as normal. Viewing from the Web Debug Toolbar ---------------------------------- From 42a5bfdc4c6f2886ff2f1ed8b181a919ca0b3fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Mon, 16 Feb 2015 13:21:45 +0000 Subject: [PATCH 6/9] Changes recommended by @cordoval --- cookbook/email/dev_environment.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cookbook/email/dev_environment.rst b/cookbook/email/dev_environment.rst index 9b55e38e914..b6f5ff17e22 100644 --- a/cookbook/email/dev_environment.rst +++ b/cookbook/email/dev_environment.rst @@ -122,8 +122,8 @@ the replaced address, so you can still see who it would have been sent to. Sending to a Specified Address but with Exceptions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Suppose you normally in your dev environment want to have all email redirected -to a specific address, (like in the above scenario to ``dev@example.com``). +Suppose you want to have all email redirected to a specific address, +(like in the above scenario to ``dev@example.com``). 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: From f07d355cdcada748c4e436f34ebb2be8e0cbce8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Mon, 16 Feb 2015 13:32:38 +0000 Subject: [PATCH 7/9] Swiched mydomain and specialdomain --- cookbook/email/dev_environment.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cookbook/email/dev_environment.rst b/cookbook/email/dev_environment.rst index b6f5ff17e22..a58c8faa41f 100644 --- a/cookbook/email/dev_environment.rst +++ b/cookbook/email/dev_environment.rst @@ -138,11 +138,11 @@ This can be done by adding the ``delivery_whitelist`` option: delivery_whitelist: # all email addresses matching this regex will *not* be # redirected to dev@example.com - - "/@mydomain.com$/" + - "/@specialdomain.com$/" - # all emails sent to admin@specialdomain.com won't + # all emails sent to admin@mydomain.com won't # be redirected to dev@example.com too - - "/^admin@specialdomain.com$/" + - "/^admin@mydomain.com$/" .. code-block:: xml @@ -155,9 +155,9 @@ This can be done by adding the ``delivery_whitelist`` option: - /@mydomain.com$/ - - /^admin@specialdomain.com$/ + /@specialdomain.com$/ + + /^admin@mydomain.com$/ .. code-block:: php @@ -167,17 +167,17 @@ This can be done by adding the ``delivery_whitelist`` option: 'delivery_whitelist' => array( // all email addresses matching this regex will *not* be // redirected to dev@example.com - '/@mydomain.com$/', + '/@specialdomain.com$/', - // all emails sent to admin@specialdomain.com won't be + // all emails sent to admin@mydomain.com won't be // redirected to dev@example.com too - '/^admin@specialdomain.com$/' + '/^admin@mydomain.com$/', ), )); In the above example all email messages will be redirected to ``dev@example.com``, -except messages sent to the ``admin@specialdomain.com`` address or to any email -address belonging to the domain ``mydomain.com``, which will be delivered as normal. +except messages sent to the ``admin@mydomain.com`` address or to any email +address belonging to the domain ``specialdomain.com``, which will be delivered as normal. Viewing from the Web Debug Toolbar ---------------------------------- From 6c4a9aaa54b7b70553e680c5d61b00ef72cf9d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Wed, 18 Feb 2015 23:12:46 +0000 Subject: [PATCH 8/9] Xml changes and line-break changes --- cookbook/email/dev_environment.rst | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cookbook/email/dev_environment.rst b/cookbook/email/dev_environment.rst index a58c8faa41f..38e791fd579 100644 --- a/cookbook/email/dev_environment.rst +++ b/cookbook/email/dev_environment.rst @@ -123,10 +123,10 @@ 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 ``dev@example.com``). -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: +(like in the above scenario to ``dev@example.com``). 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:: @@ -148,16 +148,16 @@ This can be done by adding the ``delivery_whitelist`` option: - + + - - - /@specialdomain.com$/ - - /^admin@mydomain.com$/ + + + /@specialdomain.com$/ + + /^admin@mydomain.com$/ + .. code-block:: php From e09f3e305214e107abc796e283eaa8a77b3b8160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Wed, 18 Feb 2015 23:24:29 +0000 Subject: [PATCH 9/9] More xml fixes --- cookbook/email/dev_environment.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cookbook/email/dev_environment.rst b/cookbook/email/dev_environment.rst index 38e791fd579..45719625773 100644 --- a/cookbook/email/dev_environment.rst +++ b/cookbook/email/dev_environment.rst @@ -154,9 +154,10 @@ by adding the ``delivery_whitelist`` option: - /@specialdomain.com$/ + /@specialdomain.com$/ + - /^admin@mydomain.com$/ + /^admin@mydomain.com$/ .. code-block:: php