title: How to send bulk emails in less time using php?
body: <p>I am sending bulk emails which are working but it's taking lots of time. I just sent the email only to 10 users and it takes around 2 min. I have to send the email more than 10000 users. What is the other way to send email faster? I am using PHPMailer. Would you help me in this?</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form action="process.php?key=createmail2" method="POST"&gt;
       &lt;input type="text" name="emailtemplate" placeholder="email" &gt;
       &lt;input type="text" name="subject" placeholder="subject"&gt;
        &lt;textarea name="mailbody" placeholder="mail body"&gt;&lt;/textarea&gt;
        &lt;input type="submit" name="addmail" value="Add mail" &gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Process.php</strong></p>
  
  <pre><code>&lt;?php 
  include('mail/PHPMailerConfig.php');
  switch($_GET['key']) {
  case 'createmail2':createmail2($conn);break;
  default : redirect('index.php');
  }
  
  function createmail2(){
    $array=explode(",",$_POST['emailtemplate']);
    $arrlength = count($array);
    $subject=$_POST['subject'];
    $mailbody=$_POST['mailbody'];
    send($array,$arrlength, $subject, $mailbody);
  }
   ?&gt;
  </code></pre>
  
  <p><strong>PHPMailerConfig.php</strong></p>
  
  <pre><code>&lt;?php 
  require_once('PHPMailerAutoload.php');
  function send($array,$arrlength, $subject, $mailbody){
  $mail = new PHPMailer;
  $mail-&gt;IsSMTP();
  $mail-&gt;SMTPDebug = 0;
  $mail-&gt;Debugoutput = 'html';
  $mail-&gt;Host = '*****';
  $mail-&gt;Port = 587;
  $mail-&gt;SMTPSecure = 'tls';
  $mail-&gt;SMTPAuth = true;
  $mail-&gt;Username = "abc@domain.com";
  $mail-&gt;Password = "************";
  $mail-&gt;setFrom('abc@domain.com', 'Teseting for email');
  $mail-&gt;Subject = $subject;
  $mail-&gt;Body =$mailbody;
  
  for($x = 0; $x &lt; $arrlength; $x++)
   {
     $mail-&gt;addAddress($array[$x]);
  
         if (!$mail-&gt;send())
       {
          echo "Mailer Error (" . str_replace("@", "&amp;#64;", $array[$x]) . ') ' . $mail-&gt;ErrorInfo .   '&lt;br/&gt;';
          break; //Abandon sending
       } 
         else 
       {
          echo "mail sent to : " . $array[$x] ;
  
       }
       $mail-&gt;clearAddresses();
    }
  }
  </code></pre>