Commit 09e21e66 authored by Javier Eguiluz's avatar Javier Eguiluz Committed by Fabien Potencier

Added a note about how to send emails with console commands

parent 235c4950
......@@ -97,6 +97,22 @@ The Swiftmailer provider provides a ``mailer`` service::
return new Response('Thank you for your feedback!', 201);
});
Usage in commands
~~~~~~~~~~~~~~~~~
The Swiftmailer provider sends the emails using the ``KernelEvents::TERMINATE``
event, which is fired after the response has been sent. However, as this event
isn't fired for console commands, your emails won't be sent.
For that reason, if you send emails using a command console, make sure to
flush the message spool by hand before ending the command execution. To do so,
use the following code::
$app['swiftmailer.spooltransport']
->getSpool()
->flushQueue($app['swiftmailer.transport'])
;
Traits
------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment