我使用下面的代码生成加密密码并通过用户发送邮件但是我有一个if条件,用于更新用户详细信息和新密码并发送邮件给用户,之后如果条件代码没有进入循环而不发送任何邮件任何人都可以帮助我吗?
提前致谢
$this->load->model('employee/employee','employee'); //If saving is success, then send the email with the new password
$recovery_password = $this->auth_bundle->randomKey(); //Auto generate the unique password
$encrypted_recovery_password = $this->auth_bundle->encryptPassword($recovery_password); //Encrypt the password and save in db
if($this->employee->update(array('password'=>$encrypted_recovery_password),array('email'=>$email))) {
$this->load->model('auth/users','users');
$userDetails = $this->users->getUserByEmail($email);
$this->load->library('email');
$this->email->from($this->config->item('website_email'), $this->config->item('website_email_name'));
$this->email->to($email);
$this->email->subject('Account Recovery Details');
$message = "Hi ".$userDetails['firstname']." ".$userDetails['lastname'].",<br />";
$message .= "Click here ".base_url()." and login with the following credentials.<br/><br/>";
$message .= "Email - ".$email."<br/>";
$message .= "Password - ".$recovery_password."<br/><br/>";
$message .= "In case any queries or problems with Logging-In, please contact your manager<br /><br />";
$message .= "Thank you,<br/>";
$message .= $this->config->item('company_name');
$this->email->message($message);
if($this->email->send()) {
$this->session->set_flashdata('status','Recovery password has been successfully sent to your Email');
redirect('auth/success');
}else {
$this->session->set_flashdata('error', 'Error in recovering your password. Please try again');
redirect('auth/forgotPassword');
}
}else {
$this->session->set_flashdata('error', 'Error in recovering your password. Please try again');
redirect('auth/forgotPassword');
}