Add event listener on job complete that flushes the swiftmailer spool #176
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When starting with a default symfony project the swiftmailer is set-upped to use spool for sending out mails.
https://github.com/symfony/symfony-standard/blob/7a885f1dcd2f5191f19470866aca9a472770ebcf/app/config/config.yml#L69
The spool is only flushed sent out on the kernel terminate event. When using this bundle the kernel terminate event won't be triggered. This will block the emails in memory and they are never released. A Ctrl+C will interrupt the worker but not flushing the email either.
By adding a custom EventListener to the bundle this issue could be fixed.
An other approach would be creating a specialized SwiftMailerGearmanBundle that deals with GearmanBundle events and flushes the SwiftMailer spool. But this is kind of an overload.