title: Codeigniter $this->email->send() function causing errors cannot modify header information
body: <p>I have two function in one codeigniter controller which will set the payment status of user and send email. one main function will call send_mail. send_mail function will returns true or false. then in that main function, user will be redirected </p>
  
  <p>here's the code..</p>
  
  <pre><code>function send_emai($id){  
   ..  
   ..  
   return $this-&gt;email-&gt;send(); 
  }
  
  function set_paid(){
   //set paid to user data
   $paid=$this-&gt;admin_model-&gt;set_paid($id_user);
   ..
   ..
  
   $sent=$this-&gt;send_email($id_user);
  
    if($paid &amp;&amp; $sent){
       $this-&gt;session-&gt;set_flashdata('status',
     array(
       'color'=&gt;'green',
       'message'=&gt;'status paid&lt;br/&gt;Payment Confirmation Email sent'));
     }
    else{
       $this-&gt;session-&gt;set_flashdata('status',
     array(
       'color'=&gt;'green',
       'message'=&gt;'Booth status not paid&lt;br/&gt;Payment Confirmation Email not sent'));
    }
    redirect(admin/myclass/myfunction);
  }
  </code></pre>
  
  <p>The errors i've got were </p>
  
  <pre><code>Cannot modify header information - headers already sent by (output started at C:\...\core\Exceptions.php:185)
  Filename: libraries/Session.php
  </code></pre>
  
  <p>and this one.<br></p>
  
  <pre><code>Cannot modify header information - headers already sent by (output started at C:\...\core\Exceptions.php:185)
  Filename: helpers/url_helper.php
  </code></pre>
  
  <p>I assumed this is because <code>$this-&gt;send-&gt;email()</code>. If I omitted that send function
  I could get redirected to the page and get notification set by session.<br>
  So, what can I do with this?</p>