Search code examples
codeigniter-2

Sending multiple email with codeigniter


I'm using Codeigniter 2 for my website. When send email to multiple users , on client( gmail, hotmail,..) it shows all addresse on details , how can i hide the addresses to show just the receiver address.

Thanks


Solution

  • Use bcc to send batch emails like this:

    function batch_email($recipients, $subject, $message) 
    {
      $this->email->clear(TRUE);
      $this->email->from('you@yoursite.com', 'Display Name'); 
      $this->email->to('youremailaddress@yourserver.com');
      $this->email->bcc($recipients);
      $this->email->subject($subject);
      $this->email->message($message);  
    
      $this->email->send();
    
        return TRUE;
    
    }
    

    $recipients should be a comma-delimited list or an array

    It means that you will get a copy of the email but all other recipients will be bcc'ed, so won't see each other's addresses