电子邮件验证无法在codeigniter中工作,但未找到错误

时间:2017-01-12 14:02:40

标签: php codeigniter email

我正在尝试通过电子邮件发送验证链接以激活已注册的帐户。我已成功收到邮件,但是当我点击收到的链接时,我发现错误未找到。

发送电子邮件的代码位于

之下
public function send_email($title,$fname,$lname,$email,$code)
{
    $from_email = "pavan@domain.com";
    $to_email = $this->input->post('email'); 
    $this->load->library('email'); 
    $this->email->set_mailtype("html");

    $this->email->from($from_email, 'Industry Speak'); 
    $this->email->to($email);
    $this->email->subject('Registration Confirmation Mail from Industry Speak'); 

    $message =  '</<!DOCTYPE html>
                     <html>
                     <head>
                        <title></title>
                     </head>
                     <body>
                        <p>Welcome to Industry Speak <b>'.$title.' '.$fname.' '.$lname.'</b>, </p>
                        <br>
                        <p>Thanks for the signing up!</p>
                        <P>Your account has been created, you can login with your provided credentials after you have activated your account by pressing the url below. </p>                    
                        <p>Please click this link to activate your account: </p>
                        <a href='.base_url().'Home/email_verify/'.$code.'/'.$email.'>Click Here to Activate Your Account</a>   


                     </body>
                     </html>';
        $this->email->message($message); 

        if($this->email->send()) 
        {
           $this->session->set_flashdata("msg", "<div class='alert alert-error' style='background: rgba(22, 111, 24, 0.84); color: #fff;'>
                    <button class='close' data-dismiss='alert'>&times;</button>
                    <strong>Sucess..!</strong> We sent a activation link to " .$email. " Please Activate your account. 
                </div>");   
            redirect('Home/clients');
        }
    }

我的控制器代码 email_verify 代码在

之下
function email_verify($code,$email)
    {
        $condition=array("token_code"=>md5($code),"email_id"=>$email,"client_status"=>0);
                    $email_verification=$this->data['email_veri']=$this->Frontend_model->verify_email($condition);

        if ($email_verification>0)
        {
             $this->session->set_flashdata("msg", "<div class='alert alert-error' style='background: rgba(22, 111, 24, 0.84); color: #fff;'>
                <button class='close' data-dismiss='alert'>&times;</button>
                <strong>Sucess..!</strong>Your account registered with " .$email. " is succesfully activated. Please login to your account. 
            </div>");   
            redirect('Home/clients');
        }
        else
        {
             $this->session->set_flashdata("msg", "<div class='alert alert-error' style='background: rgba(255, 87, 34, 0.96); color: #fff;'>
                <button class='close' data-dismiss='alert'>&times;</button>
                <strong>Error..!</strong> Getting error in activating your account linked with " .$email. " Please try again. 
            </div>");   
            redirect('Home/clients');
        }       

    }

点击邮件中收到的链接时出错

enter image description here

请在我做错的地方帮助我,请帮助解决此错误。提前谢谢。

1 个答案:

答案 0 :(得分:0)

您已将您的uri定义为verify/(:any),但您尝试访问email_verify/

Look at the docs

$route['product/:num'] = 'catalog/product_lookup';
  

在路由中,数组键包含要匹配的URI,而   数组值包含应重新路由到的目标。在里面   如上所示,如果在第一个中找到文字“product”   URL的一段,并在第二段中找到一个数字   而是使用“catalog”类和“product_lookup”方法。