How to send spool from swiftmailer without using command

Tom picture Tom · Sep 11, 2012 · Viewed 9.7k times · Source

How to send spool from swiftmailer without using command?

php app/console swiftmailer:spool:send --env=prod

I need to put this somehow into php file so that Server admin can add this to Schedule.

Answer

Veelkoov picture Veelkoov · Jan 5, 2013

This can also be achieved by How can I run symfony 2 run command from controller , so you don't duplicate code. Worked for me.

services.yml:

services:
    swiftmailer.command.spool_send:
        class: Symfony\Bundle\SwiftmailerBundle\Command\SendEmailCommand
        calls:
            - [ setContainer, ["@service_container"] ]

Controller code (simplified):

$this->get('swiftmailer.command.spool_send')->run(new ArgvInput(array()), new ConsoleOutput());