thinkphp邮箱验证

不言
不言 原创
2023-03-25 18:26:02 2317浏览

这篇文章主要介绍了关于thinkphp邮箱验证,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下

配置文件:config.php

return array(
    // 配置邮件发送服务器
    'MAIL_HOST' =>'smtp.163.com',//smtp服务器的名称
    'MAIL_SMTPAUTH' =>TRUE, //启用smtp认证
    'MAIL_USERNAME' =>'thinkphp_wanlala@163.com',//你的邮箱名
    'MAIL_FROM' =>'thinkphp_wanlala@163.com',//发件人地址
    'MAIL_FROMNAME'=>'yoko',//发件人姓名
    'MAIL_PASSWORD' =>'',//邮箱密码
    'MAIL_CHARSET' =>'utf-8',//设置邮件编码
    'MAIL_ISHTML' =>TRUE, // 是否HTML格式邮件

控制器Controller:

1.发送成功

    public function index(){
        $this->display();
    }
    public function doIndex(){
         if(SendMail($_POST['mail'],$_POST['title'],$_POST['content'])){
                $this->success('发送成功!');
         }
            else{
                $this->error('发送失败');
            }
    }
     public function Email(){
        header("content-type:text/html;charset=utf-8");
        $users = M('user');
        $k = $_GET['k'];
//         print_r($k);exit;
        $row = $users ->where(array('code'=>$k))->find();
//         print_r($row);         exit();
        if($row){
            $id = $row['id'];
            $data['status'] = 1;
            $wan = $users->where($id)->save($data);
            $title = "尊敬的".$data['name']."欢迎使用验证方式,请点击下面链接进行验证";
                $url = "<a href='http://localhost/collection/Home/User/email?k=".$keydate."'>立即激活</a>";
        }
        else{
            print '邮箱已激活';
        }
     }

前端View:

<form action="{:U('User/doIndex')}" method="post" enctype="multipart/form-data">
    邮箱:<input  type="text" id="mail" name="mail"/>
    标题:<input  type="text" id="title" name="title"/>
    内容<input  type="text" id="content" name="content"/>
    <input class="button" type="submit" value="发送" style="margin: 0 auto;display: block;"/>
</form>


相关推荐:

ThinkPHP邮箱类,用邮箱找回密码,向注册用户群发邮件

以上就是thinkphp邮箱验证的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
上一条:php写入文件 下一条:Yaf框架安装指南