title: How to improve the efficiency of PHP mail sending?
body: <p>I'm using PHP to send mails to multiple people in CakePHP.</p>
  <p>I'm currently using <code>foreach</code> on the recipient array, which contains mail address and names, and send the mails. It's taking quite a while to send mails and can't be done as put recipients' mail as array since there's a tiny different between all mails such as receiver's names.</p>
  <p>The mails are using same template but different parameters, is there anyway I can improve the efficiency of it?</p>
  <p>Update:  Here is the Email Template</p>
  <pre><code>&lt;?= $userSex ?&gt; &lt;?= $userName ?&gt;, &lt;br&gt;
  Thanks for ordering!&lt;br&gt;
  Your order's ID is &quot;&lt;?= $orderID ?&gt;&quot;.&lt;br&gt;
  You can check the shipping status on our website.&lt;br&gt;
  Thank you and hope you have a wonderful day.
  </code></pre>
  <p>and here's the code.</p>
  <pre><code>$mail_list = {
      [0]=&gt;{
          'userSex'=&gt;'Miss',
          'userName'=&gt;'V',
          'orderID'=&gt;'xxxxxxxx'
      },
      [1]=&gt;{
          'userSex'=&gt;'Mr.',
          'userName'=&gt;'Arasaka',
          'orderID'=&gt;'xxxxxxxx'
      }
  }
  foreach($mail_list as $target) {
      $email = new Email();
      $email-&gt;viewBuilder()-&gt;setTemplate('notify_template');
      $email-&gt;setEmailFormat('html')
              -&gt;setSubject($subject)
              -&gt;setViewVars([
                  'userSex' =&gt; $target['userSex'],
                  'userName' =&gt; $target['userName'],
                  'orderID' =&gt; $target['orderID'],
      ]);
      $emailRes = $email
          -&gt;setFrom(['no-reply@service.com' =&gt; 'service announence'])
          -&gt;setTo($target['email'])
          -&gt;setSubject($subject)
          -&gt;send();
      if (!$emailRes) {
          $res = false;
          break;
      }
  }
  </code></pre>
  <p>Every mail sent is slightly different.</p>
  <p>Is there a way to improve the mailing speed?</p>