thinkphp信箱驗證

不言
發布: 2023-03-25 18:26:02
原創
3102 人瀏覽過

這篇文章主要介紹了關於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=&#39;http://localhost/collection/Home/User/email?k=".$keydate."&#39;>立即激活</a>";
        }
        else{
            print &#39;邮箱已激活&#39;;
        }
     }
登入後複製

前端View:

<form action="{:U(&#39;User/doIndex&#39;)}" 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中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!