title: Efficient newsletter with Symfony2 and Swiftmailer
body: <p>I am trying to send a weekly newsletter to about 17.000 people, based on Symfony2 and Swiftmailer. My current problem is, that I wrote a command for the console. I can call it for example by "php app/console mail:send --newsletter 0 500". The last two numbers are additional variables for the offset and the amount of recipients which should be selected at once. What I normally would like to do is to use a cronjob, that calls this command once, in this case with the offset of 0 and the amount of 20.000 to get all recipients. This isn't working or atleast the amount of mails is just to big. My first test was to send these mails by myself, so that I can see what's happening. The script never ended until I reached the amount of 500 or less. Is this normal?</p>
  
  <p>Here is what I do:</p>
  
  <ol>
  <li>get users from the DB</li>
  <li>find articles from the DB I want to send in this newsletter</li>
  <li>run over all recipients, generate a new message by $message = \Swift_Message::newInstance()... and call $this->mailer->send($message);</li>
  <li><p>finally flush the queue by doing this:</p>
  
  <pre><code>$spool = $this-&gt;mailer-&gt;getTransport()-&gt;getSpool();
  $transport = $this-&gt;getContainer()-&gt;get('swiftmailer.transport.real');
  $spool-&gt;flushQueue($transport);
  </code></pre></li>
  </ol>
  
  <p>About what I am not sure is how I should send all these mails now. Is it wrong to just call a shell script with a cronjob, that iterates this command by changing the the offset, so that only 500 mails at once will be generated? Or what is the right way to do this? Or am I doing it totally wrong and that's why I cant send more than 500? With 1000 for example the console just doesn't react anymore until I cancel the script. I already tried to start it in the background, but it seemed that the script just wasn't working at all... and no error or something like that occured, just no reaction.</p>
  
  <p><strong>Edit:</strong> Or is it even better to use a specific mailbox to send all these mails instead of using PHP with the mail()-function, which is probably also used in the SwiftMailer?</p>
  
  <p>Thank you very much for your help!
  Manuel</p>