PHP Codeigniter密钥生成/发送电子邮件

PHP Codeigniter密钥生成/发送电子邮件,php,codeigniter,Php,Codeigniter,我试图在codeigniter中生成一个密钥并使用md5对其进行哈希,但当我通过链接将其与电子邮件一起发送给用户时,它会向其中添加更多字符。我不知道它为什么会这样 if ($this->form_validation->run()){ // Generates random key // $key = md5(uniqid()); // Loading libraries/models //

我试图在codeigniter中生成一个密钥并使用md5对其进行哈希,但当我通过链接将其与电子邮件一起发送给用户时,它会向其中添加更多字符。我不知道它为什么会这样

        if ($this->form_validation->run()){
            // Generates random key //
            $key = md5(uniqid());

            // Loading libraries/models //
            $this->load->library('email', array('mailtype' => 'html'));
            $this->load->model('model_users');

            // Contact info user //
            $this->email->from('asdf', 'Viren Badal');
            $this->email->to($this->input->post('email'));
            $this->email->subject('asdf');

            // Email message format // 
             $message = "<html>
                            <body>
                                <div>
                                       <a href='".base_url()."visitor/register_user/$key'>".base_url()."visitor/register_user/$key"."</a>
                                </div>
                            </body>
                        </html>
                        ";

            $this->email->message($message);
            if ($this->model_users->add_temp_user($key)){
                if ($this->email->send()){
                echo "An confirmation email has been sent to the following email address: ". $this->input->post('email'). ".";
                } else{
                    echo "Sending confirmation email has failed.";
                }
            } else{
                echo "An error has occurred registering!";
            }
        } else{
            $this->load->view('visitor/signup');
        }
if($this->form\u validation->run()){
//生成随机密钥//
$key=md5(uniqid());
//加载库/模型//
$this->load->library('email',array('mailtype'=>'html');
$this->load->model('model_users');
//联系信息用户//
$this->email->from('asdf','Viren Badal');
$this->email->to($this->input->post('email');
$this->email->subject('asdf');
//电子邮件格式//
$message=”
";
$this->email->message($message);
如果($this->model\u users->add\u temp\u user($key)){
如果($this->email->send()){
echo“确认电子邮件已发送至以下电子邮件地址:“..this->input->post('email')”;
}否则{
echo“发送确认电子邮件失败。”;
}
}否则{
echo“注册时发生错误!”;
}
}否则{
$this->load->view('visitor/signup');
}
这是数据库中存储的内容:

2a247fcb8a709fc3526d0672e85613d9

这是它发送到电子邮件的内容:


尝试将其发送到不同的电子邮件提供商。它是在gmail、雅虎、微软、AOL或其他网站上做的吗?您发送此电子邮件的提供商很可能在您的电子邮件到达收件箱之前对其进行了清理。我使用的是一个测试邮件服务器工具,它只侦听端口25并在本地打开我的邮件,它不会将其发送到我的真实电子邮件。此外,im注册的电子邮件只是一封随机电子邮件:test@test.comCan您
echo'.$message'并验证所有内容是否完全符合预期?在电子邮件配置中,是否将
mailtype
设置为“html”?这是我能想到的唯一一件可能会弄乱消息内容的事情。请记住,如果您发送HTML电子邮件,则必须将其作为完整网页发送。确保没有任何相对链接或相对图像路径,否则它们将无法工作。另外,代码的其余部分在哪里<代码>$this->email->message($message)不发送电子邮件。