8000 Update Swiftmailer configuration docs by jverdeyen · Pull Request #7152 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Update Swiftmailer configuration docs #7152

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

Closed
wants to merge 9 commits into from
2 changes: 1 addition & 1 deletion email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The following configuration attributes are available:

* ``type`` (how to queue the messages, ``file`` or ``memory`` is supported, see :doc:`/email/spool`)
* ``path`` (where to store the messages)
* ``delivery_address`` (an email address where to send ALL emails)
* ``delivery_addresses`` (an array of email addresses where to send ALL emails)
* ``disable_delivery`` (set to true to disable delivery completely)

Sending Emails
Expand Down
25 changes: 15 additions & 10 deletions email/dev_environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,22 @@ will not be sent when you run tests, but will continue to be sent in the
If you'd also like to disable deliver in the ``dev`` environment, simply
add this same configuration to the ``config_dev.yml`` file.

Sending to a Specified Address
------------------------------
.. _sending-to-a-specified-address:

You can also choose to have all email sent to a specific address, instead
Sending to a Specified Address(es)
----------------------------------

You can also choose to have all email sent to a specific address or a list of addresses, instead
of the address actually specified when sending the message. This can be done
via the ``delivery_address`` option:
via the ``delivery_addresses`` option:

.. configuration-block::

.. code-block:: yaml

# app/config/config_dev.yml
swiftmailer:
delivery_address: 'dev@example.com'
delivery_addresses: ['dev@example.com']

.. code-block:: xml

Expand All @@ -78,14 +80,16 @@ via the ``delivery_address`` option:
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">

<swiftmailer:config delivery-address="dev@example.com" />
<swiftmailer:config>
<swiftmailer:delivery-address>dev@example.com</swiftmailer:delivery-address>
</swiftmailer:config>
</container>

.. code-block:: php

// app/config/config_dev.php
$container->loadFromExtension('swiftmailer', array(
'delivery_address' => "dev@example.com",
'delivery_addresses' => array("dev@example.com"),
));

Now, suppose you're sending an email to ``recipient@example.com``.
Expand Down Expand Up @@ -139,7 +143,7 @@ by adding the ``delivery_whitelist`` option:

# app/config/config_dev.yml
swiftmailer:
delivery_address: dev@example.com
delivery_addresses: ['dev@example.com']
delivery_whitelist:
# all email addresses matching these regexes will be delivered
# like normal, as well as being sent to dev@example.com
Expand All @@ -158,19 +162,20 @@ by adding the ``delivery_whitelist`` option:
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/swiftmailer http://symfony.com/schema/dic/swiftmailer/swiftmailer-1.0.xsd">

<swiftmailer:config delivery-address="dev@example.com">
<swiftmailer:config>
<!-- all email addresses matching these regexes will be delivered
like normal, as well as being sent to dev@example.com -->
<swiftmailer:delivery-whitelist-pattern>/@specialdomain\.com$/</swiftmailer:delivery-whitelist-pattern>
<swiftmailer:delivery-whitelist-pattern>/^admin@mydomain\.com$/</swiftmailer:delivery-whitelist-pattern>
<swiftmailer:delivery-address>dev@example.com</swiftmailer:delivery-address>
</swiftmailer:config>
</container>

.. code-block:: php

// app/config/config_dev.php
$container->loadFromExtension('swiftmailer', array(
'delivery_address' => "dev@example.com",
'delivery_addresses' => array("dev@example.com"),
'delivery_whitelist' => array(
// all email addresses matching these regexes will be delivered
// like normal, as well as being sent to dev@example.com
Expand Down
25 changes: 15 additions & 10 deletions reference/configuration/swiftmailer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Configuration
* `antiflood`_
* `threshold`_
* `sleep`_
* `delivery_address`_
* `delivery_addresses`_
* `delivery_whitelist`_
* `disable_delivery`_
* `logging`_
Expand Down Expand Up @@ -145,15 +145,21 @@ sleep
Used with ``Swift_Plugins_AntiFloodPlugin``. This is the number of seconds
to sleep for during a transport restart.

delivery_address
~~~~~~~~~~~~~~~~
.. _delivery-address:

**type**: ``string``
delivery_addresses
~~~~~~~~~~~~~~~~~~

**type**: ``array``

.. note::

In previous versions, this option was called ``delivery_address``.

If set, all email messages will be sent to this address instead of being
If set, all email messages will be sent to these addresses instead of being
sent to their actual recipients. This is often useful when developing. For
example, by setting this in the ``config_dev.yml`` file, you can guarantee
that all emails sent during development go to a single account.
that all emails sent during development go to one or more some specific accounts.

This uses ``Swift_Plugins_RedirectingPlugin``. Original recipients are available
on the ``X-Swift-To``, ``X-Swift-Cc`` and ``X-Swift-Bcc`` headers.
Expand All @@ -163,9 +169,9 @@ delivery_whitelist

**type**: ``array``

Used in combination with ``delivery_address``. If set, emails matching any
Used in combination with ``delivery_address`` or ``delivery_addresses``. If set, emails matching any
of these patterns will be delivered like normal, as well as being sent to
``delivery_address``. For details, see the
``delivery_address`` or ``delivery_addresses``. For details, see the
:ref:`How to Work with Emails during Development <sending-to-a-specified-address-but-with-exceptions>`
article.

Expand Down Expand Up @@ -207,7 +213,7 @@ Full Default Configuration
antiflood:
threshold: 99
sleep: 0
delivery_address: ~
delivery_addresses: []
disable_delivery: ~
logging: '%kernel.debug%'

Expand All @@ -229,7 +235,6 @@ Full Default Configuration
encryption=""
auth_mode=""
sender_address=""
delivery_address=""
disable_delivery=""
logging="%kernel.debug%"
>
Expand Down
0