【问题标题】:Codeigniter ion auth forgot password not sending emailCodeigniter ion auth 忘记密码不发送电子邮件
【发布时间】:2014-08-11 21:49:37
【问题描述】:

如果我提交重置电子邮件的新密码,CodeIgniter 不会发送邮件。但它返回一条消息,密码重置电子邮件已发送。所以它不会触发错误。

我正在使用 CodeIgniter 2.1.4 和 IonAuth 2.5.2

$config['use_ci_email'] = TRUE;

我已经将此配置设置为 TRUE,但仍然不发送邮件。

【问题讨论】:

  • 任何解决方案了吗?

标签: php codeigniter email authentication ion-auth


【解决方案1】:

不要更改“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");
            }

【讨论】:

    【解决方案2】:

    我在 codeigniter 中使用配置 应用程序/config/email.php

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

    应用程序/config/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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-10
      • 2014-01-23
      • 2016-08-31
      • 2011-02-19
      • 2012-02-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多