- You need to < make a call
$this->load->library('email');in the controller, as well as for email to work in CI. - Also, in your code:
$fromemailnot initialized. - Your server must have SMTP support .
- $ config must be declared as an array before assigning values and keys.
Work code:
$this->load->library('email');
$fromemail="ad@c.com";
$toemail = "user@email.id";
$subject = "Mail Subject is here";
$data=array();
$mesg = $this->load->view('template/email','',true);
$config=array(
'charset'=>'utf-8',
'wordwrap'=> TRUE,
'mailtype' => 'html'
);
$this->email->initialize($config);
$this->email->to($toemail);
$this->email->from($fromemail, "Title");
$this->email->subject($subject);
$this->email->message($mesg);
$mail = $this->email->send();
Edit: $mesg = $this->load->view('template/email',true); , . true, , .
Edit:
$this->load->view(); , $mesg = $this->load->view(view,data,true);,