我想使用模板发送电子邮件。我试过这段代码,但是它给出了这个错误。
严重程度:4096 消息:类CI_Loader的对象无法转换为字符串
我的代码是:
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;
}
}
答案 0 :(得分:2)
如果要将视图作为字符串返回,则必须按如下方式加载:
FcgidIOTimeout 3000
FcgidBusyTimeout 3000
答案 1 :(得分:0)
应该像这样检查:
<?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;
}
}
?>