- You need to call
$this->load->library('email');
within the controller as well for the email in CI to work.
- Also , in your code :
$fromemail
is not initialized.
- You need to have SMTP support on your server.
- $config should be declared as an array before assigning values and keys.
Working 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',$data,true);
// or
$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);
should be having the true as pointed out by lycanian. By setting it as true , it doesn't send data to the output stream but it will return as a string.
Edit:
$this->load->view();
need a second parameter with data or empty like $mesg = $this->load->view(view,data,true);
, if not it wont work
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…