1
1
How to Spool Email
2
2
==================
3
3
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:
15
16
16
17
.. configuration-block ::
17
18
@@ -50,10 +51,19 @@ In order to use the spool you will need to use the following config:
50
51
)
51
52
));
52
53
54
+ .. tip ::
53
55
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:
57
67
58
68
.. code-block :: bash
59
69
@@ -71,6 +81,6 @@ You can also set the time limit in seconds:
71
81
72
82
php app/console swiftmailer:spool:send --time-limit=10
73
83
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