Thursday 10 July 2014

Sending email to multiple in codeigniter from localhost

Sending email to multiple in codeigniter from localhost


public function mail_send()
{
    $config = Array(
  'protocol' => 'smtp',
  'smtp_host' => 'ssl://smtp.googlemail.com',
  'smtp_port' => 465,
  'smtp_user' => 'xxxx@gmail.com', // change it to yours
  'smtp_pass' => 'xxxx', // change it to yours
  'mailtype' => 'html',
  'charset' => 'iso-8859-1',
  'wordwrap' => TRUE
);

        $message = 'Hi This is Test Mail';
        $this->load->library('email', $config);
      $this->email->set_newline("\r\n");
      $this->email->from('xxxx@gmail.com'); // change it to yours
      $this->email->to(array('xxxx@gmail.com','xxxx1@gmail.com'));// change it to yours
      $this->email->subject('Test mail from BNR');
      $this->email->message($message);
      if($this->email->send())
     {
      echo 'Email sent.';
     }
     else
    {
     show_error($this->email->print_debugger());
    }

}

No comments:

Post a Comment