title: Codeigniter: Email attachment of last emails not cleared while sending multiple emails in loop
body: <p>My code sends multiple emails in loop with attachment,</p>
  
  <p>Problem is attachments of last(previous all) emails get attached to next email.</p>
  
  <p>ex. suppose 3 emails in database with 1 attachment in each(a1.pdf, a2.pdf, a3.pdf)
  then, 
  it sends email with attachment as</p>
  
  <p>email 1:</p>
  
  <p>attachment :a1.pdf</p>
  
  <p>email 2:</p>
  
  <p>attachment :a1.pdf, a2.pdf</p>
  
  <p>email 3:</p>
  
  <p>attachment :a1.pdf, a2.pdf, a3.pdf</p>
  
  <p><strong>I am using codeigniter framework.</strong></p>
  
  <p>My code is (this code is called in loop)</p>
  
  <p>.
  .
  .</p>
  
  <p>$this->email->subject($item->subject);</p>
  
  <pre><code>        $this-&gt;email-&gt;message($message);
          $attachments='';
          if(strlen($item-&gt;attachment) &gt; 5)
          {
              $attachments = explode(',', $item-&gt;attachment);
              foreach($attachments as $attachment)
              {
                  if(strlen($attachment)&gt;5)
                  $this-&gt;email-&gt;attach(FCPATH . 'attachments/' . $attachment);                    
              }                
  
          }
  
        $this-&gt;email-&gt;send();
  </code></pre>
  
  <p>.
  .
  .</p>