大家好,我目前正在开发CodeIgniter应用程序,用户可以在其中创建自己的帐户等。
我试图创建一个功能来恢复密码以防丢失或遗忘。 这是我的代码:
public function admin_recover(){
$this->form_validation->set_rules('email', 'Email', 'trim|required|min_length[7]|valid_email');
if($this->form_validation->run() == FALSE){
//Load View Into Template
$this->template->load('admin', 'login', 'users/recover');
} else {
//Get Post Data
$email = $this->input->post('email');
$password = $this->input->post('password');
$user_email = $this->User_model->get_list();
if($user_email){
$user_email_data = array(
'email' => true
);
///////// Sending email
// Configure email library
$config['wordwrap'] = FALSE;
$config['mailtype'] = 'html';
$config['crlf'] = '\r\n';
$config['charset']='utf-8';
$config['newline']="\r\n";
$config['priority']=1;
$config['protocol']='smtp';
$config['smtp_host']='ssl://smtp.gmail.com';
$config['smtp_port']='25';
$config['smtp_timeout']='30';
$config['smtp_user']='kuaf1998@gmail.com';
$config['smtp_pass']='mypassword';
$config['newline']="\r\n";
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from('no-reply@socialgeek.com', 'Social Geek');
$this->email->to('kebin1421@hotmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
if($this->email->send())
$this->session->set_flashdata("success","Email sent successfully.");
else
$this->session->set_flashdata("error","Error in sending Email.");
echo $this->email->print_debugger();
//////////////
}
}
}
我使用gmail smtp服务从我的localhost发送电子邮件,但我仍然无法实现。知道如何解决这个问题?
我已经对(我使用xampp)我的xampp> php> php.ini上的ini文件进行了一些更改
当我进入视图时,我收到此错误:
感谢您的帮助。
答案 0 :(得分:0)
尝试使用下面的这些配置设置,让我知道它是否适合您。
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'user@gmail.com',
'smtp_pass' => 'yourpassword',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);