php - Using a HTML Mail template with codeigniter -
i using codeigniter email class send emails when user register website or perform activity inside website.
the thing that, simple code below can send simple html emails. , have pass entire html message function. there way load entire template in function , pass message placed inside template in codeigniter views.
$message = 'thank order \n'; $message .= 'we contact soon'; $this->email($message); public function email($message = null){ $this->load->library('email'); $this->email->mailtype('html'); $this->email->from('sohanmax2@gmail.com', 'sohan kc'); $this->email->to('sohanmax02@gmail.com'); $this->email->subject('email test'); $this->email->message($message); $this->email->send(); }
why don't stated? :) email classes message method requires string passed. load view , pass returned string method.
public function email($message = null){ $this->load->library('email'); $mydata = array('message' => 'i message passed view'); $message = $this->load->view('my_email_template', $mydata, true); $this->email->mailtype('html'); $this->email->from('sohanmax2@gmail.com', 'sohan kc'); $this->email->to('sohanmax02@gmail.com'); $this->email->subject('email test'); $this->email->message($message); $this->email->send(); }
Comments
Post a Comment