Skip to content

Commit f20fd8d

Browse files
committed
minor #7104 warning about using swiftmail with file spool and lazy loading (nykopol, javiereguiluz)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #7104). Discussion ---------- warning about using swiftmail with file spool and lazy loading PR to fix #5596 Commits ------- 0a19f77 Fixed minor syntax issues and typos ef3ab27 more precision on class name, and lazy service f97db93 add warning about the limitation on using swiftmail with file spool and lazy loading
2 parents 549f8ad + 0a19f77 commit f20fd8d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

email/spool.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,21 @@ You can also set the time limit in seconds:
141141
Of course you will not want to run this manually in reality. Instead, the
142142
console command should be triggered by a cron job or scheduled task and run
143143
at a regular interval.
144+
145+
.. caution::
146+
147+
When you create a message with SwiftMailer, it generates a ``Swift_Message``
148+
class. If the ``swiftmailer`` service is lazy loaded, it generates instead a
149+
proxy class named ``Swift_Message_<someRandomCharacters>``.
150+
151+
If you use the memory spool, this change is transparent and has no impact.
152+
But when using the filesystem spool, the message class is serialized in
153+
a file with the randomized class name. The problem is that this random
154+
class name changes on every cache clear. So if you send a mail and then you
155+
clear the cache, the message will not be unserializable.
156+
157+
On the next execution of ``swiftmailer:spool:send`` an error will raise because
158+
the class ``Swift_Message_<someRandomCharacters>`` doesn't exist (anymore).
159+
160+
The solutions are either to use the memory spool or to load the
161+
``swiftmailer`` service without ``lazy`` option (see :doc:`/service_container/lazy_services`).

0 commit comments

Comments
 (0)