How to send spool from swiftmailer without using command

前端 未结 2 979
情话喂你
情话喂你 2021-02-15 14:55

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

2条回答
  •  無奈伤痛
    2021-02-15 15:37

    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());
    

提交回复
热议问题