首页 文章

Codeigniter ion auth忘记密码不发送电子邮件

提问于
浏览
3

如果我提交以将新密码重置为我的电子邮件,则CodeIgniter不会发送邮件 . 但它正在返回密码重置电子邮件已发送的消息 . 所以它不会触发错误 .

我正在使用CodeIgniter 2.1.4和IonAuth 2.5.2

$config['use_ci_email'] = TRUE;

我已将此配置设置为TRUE,但仍未发送邮件 .

2 回答

  • 0

    我在codeigniter application / config / email.php中使用config

    $config['protocol'] = 'mail';
    $config['wordwrap'] = false;
    $config['mailtype'] = 'html';
    

    应用/配置/ autoload.php

    $autoload['libraries'] = array('lang','template', 'email','form_validation','session','encrypt','pagination','upload','database' );
    

    在控制器中

    $this->email->from(MAIL,MAIL);
    $this->email->to($mailto);
    $this->email->subject($text_subject);
    $this->email->message($this->load->view('email/template_email',$data,TRUE));
    $this->email->send();
    
  • 0

    不要改变'ion_auth.php'中的任何内容 . 文件就像:

    $config['use_ci_email'] = FALSE; // Send Email using the builtin CI email class, if false it will return the code and the identity
    $config['email_config'] = array(
        'mailtype' => 'html',
    );
    

    然后'Auth.php'这是控制器文件改变一些代码,如:

    if ($forgotten)
                {
                    // if there were no errors
    //              $this->session->set_flashdata('message', $this->ion_auth->messages());
    //              redirect("auth/login"); //we should display a confirmation page here instead of the login page
                                $config = [
                                                'protocol' => 'smtp',
                                                'smtp_host' => 'ssl://smtp.googlemail.com',
                                                'smtp_port' => 465,
                                                'smtp_user' => 'xxx',
                                                'smtp_pass' => 'xxx',
                                                'mailtype' => 'html'
                                            ];
                                $data = array(
                                    'identity'=>$forgotten['identity'],
                                    'forgotten_password_code' => $forgotten['forgotten_password_code'],
                                );
                                $this->load->library('email');
                                $this->email->initialize($config);
                                $this->load->helpers('url');
                                $this->email->set_newline("\r\n");
    
                                $this->email->from('xxx');
                                $this->email->to("xxx");
                                $this->email->subject("forgot password");
                                $body = $this->load->view('auth/email/forgot_password.tpl.php',$data,TRUE);
                                $this->email->message($body);
    
                                if ($this->email->send()) {
    
                                    $this->session->set_flashdata('success','Email Send sucessfully');
                                    return redirect('auth/login');
                                } 
                                else {
                                    echo "Email not send .....";
                                    show_error($this->email->print_debugger());
                                }
                }
                else
                {
                    $this->session->set_flashdata('message', $this->ion_auth->errors());
                    redirect("auth/forgot_password");
                }
    

相关问题