[英]How to send email using template in Codeigniter
I want to send email using template. 我想使用模板发送电子邮件。 I have tried this code but it gives this error. 我已经尝试过此代码,但它给出了此错误。
Severity: 4096 Message: Object of class CI_Loader could not be converted to string 严重级:4096消息:CI_Loader类的对象无法转换为字符串
My code is: 我的代码是:
public function email_submit_change_password(){
$this->load->library('email');
$email = $this->input->post('email');
$check = $this->db->query("SELECT * FROM tbl_profile_main WHERE connect_to_email='".$email."';");
if($check->result()!=NULL){
$test = $this->load->view('includes/test');
$this->email->from('itsthunder07@gmail.com', 'Your Name');
$this->email->to($email);
$this->email->subject('Password Reset');
$this->email->message($test);
if($this->email->send()){
$this->db->query("UPDATE tbl_profile_main SET token_='".$token."' WHERE connect_to_email='".$email."';");
$this->session->set_userdata('email_send','success');
return 1;
// return 5;
}
}else{
$this->session->set_userdata('email_incorrect','error');
return 0;
}
}
如果要以字符串形式返回视图,则必须按以下方式加载它:
$test = $this->load->view('includes/test', '', true);
there should be check like this: 应该有这样的检查:
<?php
$check = $this->db->query("SELECT * FROM tbl_profile_main WHERE connect_to_email='".$email."';");
if($check->num_rows() > 0) { // check data exists or not
$r = $check->result_array();
if(!empty($r)) {
// send email process
} else {
$this->session->set_userdata('email_incorrect','error');
return 0;
}
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.