thinkphp邮箱验证

php教程评论369 views阅读模式

这篇文章主要介绍了关于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教程网其它相关文章!

企鹅博客
  • 本文由 发表于 2020年7月4日 06:35:32
  • 转载请务必保留本文链接:https://www.qieseo.com/248388.html

发表评论