php - Sending email with one or more recipient in codeigniter -


i have field in table contains email of users. field looked :

| no_request |    addresed_to                                              | +--------------------------------------------------------------------------+ |   001      |    email1@domain.com, email2@domain.com, email3@domain.com  | 

i use mvc concept using codeigniter php. create model :

public function sendemail($no_request){     $this->db->select('approved_to');     $this->db->where('no_request', $no_request);     $query = $this->db->get('tbl_requestfix');      return $query->row(); } 

and controller :

public function sendrequestkeatasan($name, $email_user, $addressed_to, $complaint) {     $config = array(         'protocol' => 'smtp',         'smtp_host' => 'smtp.xxx.xxx,         'smtp_port' => 25,         'smtp_user' => $email_,          'mailtype' => 'html',         'charset' => 'iso-8859-1',         'wordwrap' => true     );      $message = date("h:i:s");     $this->load->library('email', $config);     $this->email->set_newline("\r\n");     $this->email->from($email_user, $name);     $this->email->to($addressed_to);     $this->email->subject("$no_request);     $this->email->message("$keluhan");      if ($this->email->send()) {         echo 'email sent.';     } else {         show_error($this->email->print_debugger());     } } 

as can see, in addresed in table, have 3 emails address. so, how can sent email 3 users on ?

as codeigniter docs provided,

sets email address(s) of recipient(s). can single email, comma-delimited list or array

for example :

$this->email->to('someone@example.com'); $this->email->to('one@example.com, two@example.com, three@example.com'); $this->email->to(array('one@example.com', 'two@example.com', 'three@example.com')); 

in case, save email address comma separated value. so, can send them this.

$result = $this->your_model->sendemail($no_request); sendrequestkeatasan($name, $email_user, $result->addressed_to, $complaint); 

hope useful you.


Popular posts from this blog