Commit b40e5b2b authored by Fabien Potencier's avatar Fabien Potencier

minor #917 Added a note about how to send emails with console commands (javiereguiluz)

This PR was squashed before being merged into the 1.2.x-dev branch (closes #917).

Discussion
----------

Added a note about how to send emails with console commands

Commits
-------

09e21e66 Added a note about how to send emails with console commands
parents 235c4950 09e21e66
......@@ -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