spod
spod

Reputation: 416

sending email using templates in codeigniter

I have to send weekly reports to my users. I am using an email template from view. My code in controller is

function sendWeeklyMail(){
    if(!$this->session->userdata('some'))
        redirect('admin/admin','refresh');
   $data=$this->admin_model->getUserData();
   foreach($data as $u){
        $this->email->clear();

        $this->email->to($u->Email);
        $this->email->from('[email protected]');
        $this->email->subject('Here is your info '.$name);
        $this->email->message('email/report',$data,'true');
        $this->email->send();
       }
   }
}

My question is how do i send the data so that i can show the user some data in the body of the message. Usually codeigniter takes data as $data['user_data']

Upvotes: 11

Views: 16444

Answers (1)

umefarooq
umefarooq

Reputation: 4574

hi you have to do the following step to send email using templates

$data['name'] = "Mike"; 
$data['email'] = '[email protected]';
$data['message_body'] = "any message body you want to send";

$message = $this->load->view('email/report',$data,TRUE); // this will return you html data as message
$this->email->message($message);

Upvotes: 24

Related Questions