Vincent
Vincent

Reputation: 852

Sending html email in Codeigniter

I am sending a template html in codeigniter and in fact my email is working perfectly fine.

My problem is how i send a template of html to the email. I got an error because of the variables passed to.

public function send_email_accountability($C11, $C4, $C8,$C12)
{
    date_default_timezone_set('Asia/Manila');
    $message = $this->load->view('sample_html',$data,TRUE); 
    $this->load->library('email');
    $this->email->set_mailtype("html");
    $this->email->from('[email protected]', 'EMAIL');
    $this->email->to($C11); 
    $this->email->subject('Accountability for'. $C12);
    $this->email->message($message);
}

I receive the email but inside the email is php error because the $data cannot be passed to. I looked at other stackoverflow problems and it didn't help my problem.

Upvotes: 0

Views: 6975

Answers (3)

ReNiSh AR
ReNiSh AR

Reputation: 2852

you are using a data array ($data) to the view, but no values is assigned to it, just assign any value to array to avoid the error,

$data['logo_img'] = 'images/logo.png';     // add this line before loading the view

This logo image is located as $logo_img in the view sample_html...

Upvotes: 0

Ripa Saha
Ripa Saha

Reputation: 2536

use PHPmailer. It will help You. I also use it. You can get all information about PHPmailer from here

Upvotes: 0

Anand Somasekhar
Anand Somasekhar

Reputation: 596

public function send_email_accountability($C11, $C4, $C8,$C12)
{
    date_default_timezone_set('Asia/Manila');
    $this->load->library('email');
    $data['title']='HELLO WORLD';
    $this->email->from('[email protected]', 'EMAIL');
    $this->email->to($C11); 
    $this->email->subject('Accountability for'. $C12);
    $this->email->set_mailtype("html");
    $msg = $this->load->view('sample_html',$data,TRUE);
    $this->email->message($msg);
    $this->email->send();
}


Try this one

Upvotes: 2

Related Questions