Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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']

like image 574
spod Avatar asked May 19 '13 05:05

spod


1 Answers

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);
like image 105
umefarooq Avatar answered Nov 09 '22 03:11

umefarooq