title: Email sending error in Codeigniter " fwrite(): send of 6 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host."
body: <p><strong>Want to handle the situation when the smtp host server is restarted while sending emails. Emails sending script should not get terminated due to the runtime error. It should try to reconnect to server host and send the emails again</strong></p>
  <p>My Code :</p>
  <pre><code>$config=array('protocol'=&gt;'smtp',
                  'smtp_host'=&gt;'example.com',     
                  'smtp_port'=&gt;587,
                  'smtp_user'=&gt;'******',
                  'smtp_pass'=&gt;'***', 
                  'priority'=&gt; 1,
                  'smtp_timeout'=&gt;'30',
                  //'smtp_keepalive'=&gt;TRUE,
                  'mailtype'  =&gt; 'html',              
                  'charset'=&gt;'utf-8',
                  'wordwrap'=&gt;True);  
   foreach($res2 as $email)
  {
    $this-&gt;email-&gt;from($fromemail,$fromname);
                  
                  $this-&gt;email-&gt;to($email);              
                  $this-&gt;email-&gt;subject('Dummy Email');               
                  $body=$emailDesign2;
                  $this-&gt;email-&gt;message($body);
                  
                  
                  
                  
                                  
                      if($this-&gt;email-&gt;send())
                      {
                          echo &quot;Mail Sent&lt;br/&gt;&quot;;
                          $total++;
                      }
                      else
                      {
                           echo &quot;Mail Not Sent&quot;;
                      }
  
  }
  
  </code></pre>