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']
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With