[FEATURE] Integrate Swift Mailer's spool transport
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Documentation / Changelog / master / Feature-76349-IntegrateSwiftMailersSpoolTransportIntoTYPO3.rst
1 .. include:: ../../Includes.txt
2
3 =====================================================================
4 Feature: #76349 - Integrate Swift Mailer's spool transport into TYPO3
5 =====================================================================
6
7 See :issue:`76349`
8
9 Description
10 ===========
11
12 The default behavior of the TYPO3 mailer is to send the email messages immediately. You may, however, want to avoid the performance hit of the communication to the email server, which could cause the user to wait for the next page to load while the email is sending. This can be avoided by choosing to "spool" the emails instead of sending them directly.
13
14 This makes the mailer to not attempt to send the email message but instead save it somewhere such as a file. Another process can then read from the spool and take care of sending the emails in the spool. Currently only spooling to file or memory is supported.
15
16 Spool Using Memory
17 ==================
18
19 When you use spooling to store the emails to memory, they will get sent right before the kernel terminates. This means the email only gets sent if the whole request got executed without any unhandled exception or any errors. To configure this spool, use the following configuration:
20
21 .. code-block:: php
22
23 $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_spool_type'] = 'memory';
24
25
26 Spool Using Files
27 =================
28
29 When you use the filesystem for spooling, TYPO3 by default stores the spools files in `typo3temp/var/messages/`. This folder will contain files for each email in the spool. So make sure this directory is writable by TYPO3.
30
31 In order to use the spool with files, use the following configuration:
32
33 .. code-block:: php
34
35 $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_spool_type'] = 'file';
36
37 If you want to store the spool somewhere else, you can define a different directory using the following setting:
38
39 .. code-block:: php
40
41 $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_spool_filepath'] = '/folder/of/choice';
42
43
44 Now, when TYPO3 is instructed to send an email, it will not actually be sent but instead added to the spool. Sending the messages from the spool is done separately. There is a console command to send the messages in the spool:
45
46 .. code-block:: php
47
48 ./typo3/sysext/core/bin/typo3 swiftmailer:spool:send
49
50
51 It has an option to limit the number of messages to be sent:
52
53 .. code-block:: php
54
55 ./typo3/sysext/core/bin/typo3 swiftmailer:spool:send --message-limit=10
56
57
58 You can also set the time limit in seconds:
59
60 .. code-block:: php
61
62 ./typo3/sysext/core/bin/typo3 swiftmailer:spool:send --time-limit=10
63
64
65 Of course you will not want to run this manually in reality. Instead, the console command should be triggered by a cron job or scheduled task and run at a regular interval.
66
67 .. index:: PHP-API, NotScanned