title: using swiftmailer to send bulk email
body: <p>I'm using swiftmailer to send emails to users when someone registers on my site.
  When i want to send out an email to them members i used the same function but just did a while loop of all my members to send an email to all of them.</p>
  
  <p>The problem im having is this times out at around 120 seconds when its only 10-20% the way through my members table. Whats the fastest way round fixing this? Can i add a sleep or???</p>
  
  <p>The code is</p>
  
  <pre><code>&lt;?php
  include ('functions.php');
  connect();
  require_once 'lib/swift_required.php';
  
  $result = mysql_query("SELECT member_id, email, firstname FROM members")
  or die ("Error - Something went wrong.");
  
  $i = 1;
  while($row = mysql_fetch_array($result)){
      echo nl2br("memberid = $row[member_id]");
      $useremail = $row['email'];
      $user_name = $row['firstname'];
      $transport = Swift_SmtpTransport::newInstance('my smtp server', 25);
  
      $mailer = Swift_Mailer::newInstance($transport);
  
      $message = Swift_Message::newInstance()
          -&gt;setSubject('my subject')
          -&gt;setFrom(array('noreply@mydomain.com' =&gt; 'mydomain'))
          -&gt;setTo(array("$useremail" =&gt;" $user_name"))
          -&gt;setBody(
             '&lt;html&gt;' .
             '&lt;head&gt;&lt;/head&gt;' .
             '&lt;body&gt;' .
                  my email body
             '&lt;/body&gt;' .
             '&lt;/html&gt;',
             'text/html'
              );
  
      if ($mailer-&gt;send($message)){
          mail("registrations@mydomain.com", "ok", "email sent to '$useremail'", "Sent ok");
      }
  $i++;
  }
  </code></pre>