Reputation: 936
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).
Upvotes: 2
Views: 1712
Reputation: 10136
You can find the solution for this issue in the How to Spool Email part of the Symfony Cookbook.
Upvotes: 1
Reputation: 10302
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:partial
That 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
Upvotes: 1