I am working on a mailing tool with Symfony 2.1 framework and SwiftMailer.
This tool needs to handle thousands of emails, but by groups of 500 because of a smtp server constraint (I can’t modify it). It needs to wait few minutes between each wave.
I totally don’t know how to do this.
The server running the app is on a Windows machine with Apache, and PHP 5.4. I could use a CRON task but I didn’t find anything about CRON and Symfony (I found that with Symfony 1.1, not really up to date).
I’d use Symfony’s built-in Command component here. You’re probably familiar with the normal Commands that come packaged with Symfony… Things like
app/console generate:bundle, etc.You can use the ContainerAwareCommand class to write your own.
Here are the steps you’ll need to take:
$this->getContainer()->get("doctrine")./path/to/symfony/app/console email:send:partialThat should get you there. Here are a few references for the ContainerAwareCommand class:
http://symfony.com/doc/2.0/cookbook/console/console_command.html
http://api.symfony.com/2.1/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.html