Skip to content

Commit ad7f382

Browse files
committed
Proofing the spool cookbook article - very nice
1 parent 0b97f99 commit ad7f382

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

cookbook/email/spool.rst

+27-17
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
How to Spool Email
22
==================
33

4-
When you are using the ``SwiftmailerBundle`` to send emails from a Symfony2
5-
application it will by default send the email immediately. You may want
6-
to avoid the performance hit of the communication between ``Swiftmailer``
7-
and the email transport taking place at the time. This can be avoided by
8-
choosing to spool the emails instead of sending them directly. This means
9-
that ``Swiftmailer`` does not attempt to send the email but instead saves
10-
the message to somewhere such as a file. Another process can then read from
11-
the spool and take care of sending of the email. Currently only spooling to
12-
file is supported by ``Swiftmailer``.
13-
14-
In order to use the spool you will need to use the following config:
4+
When you are using the ``SwiftmailerBundle`` to send an email from a Symfony2
5+
application, it will default to sending the email immediately. You may, however,
6+
want to avoid the performance hit of the communication between ``Swiftmailer``
7+
and the email transport, which could cause the user to wait for the next
8+
page to load while the email is sending. This can be avoided by choosing
9+
to "spool" the emails instead of sending them directly. This means that ``Swiftmailer``
10+
does not attempt to send the email but instead saves the message to somewhere
11+
such as a file. Another process can then read from the spool and take care
12+
of sending the emails in the spool. Currently only spooling to file is supported
13+
by ``Swiftmailer``.
14+
15+
In order to use the spool, use the following configuration:
1516

1617
.. configuration-block::
1718

@@ -50,10 +51,19 @@ In order to use the spool you will need to use the following config:
5051
)
5152
));
5253
54+
.. tip::
5355

54-
Now when your app sends an email it will not actually be sent but added
55-
to the spool. Sending the messages from the spool is done separately. There
56-
is a console command to send the messages in the spool:
56+
If you want to store the spool somewhere with your project directory,
57+
remember that you can use the `%kernel.root_dir%` parameter to reference
58+
the project's root:
59+
60+
.. code-block:: yaml
61+
62+
path: %kernel.root_dir%/app/spool
63+
64+
Now, when your app sends an email, it will not actually be sent but instead
65+
added to the spool. Sending the messages from the spool is done separately.
66+
There is a console command to send the messages in the spool:
5767

5868
.. code-block:: bash
5969
@@ -71,6 +81,6 @@ You can also set the time limit in seconds:
7181
7282
php app/console swiftmailer:spool:send --time-limit=10
7383
74-
Of course you will not want to run this manually in actual use, the console
75-
command should be triggered by a cron job or scheduled task and run at
76-
a regular interval.
84+
Of course you will not want to run this manually in reality. Instead, the
85+
console command should be triggered by a cron job or scheduled task and run
86+
at a regular interval.

0 commit comments

Comments
 (0)