i want send email in codeignitor controller. have used foreach loop in body multiple attachment. it's not working. give me suggestion here controller function.
function emailsend($ship_item_data{ //$link = base_url(); $email ="abc.develop01@gmail.com"; $this->load->library('email'); $config['mailtype'] = "html"; $this->email->initialize($config); $this->email->from($email, 'ghl sports'); $this->email->to($email); $this->email->subject('sold items detail'); $msg='<html> <head> <title>sold item</title> </head> <body> dear ghl sports client. <p>this items heas been sold.</p><ul>'; foreach($ship_item_data $data){ $item = $data['image_name']; $this->email->attach("sold/".$item); $msg .= '<li>'. $item .'</li>'; } $msg .='</u> please reply email not monitored. </body> </html>'; $this->email->message($msg); //$link = base_url(); //$this->email->attach("sold/1.jpg"); //send mail if($this->email->send()) { echo "email send successfully"; }else{ echo "email not send"; }
i have include email library in constructor.
$this->load->helper('path'); $this->load->library('email');
you need use $this->email->clear(true); clean out variables set within loop.