Home >Backend Development >PHP Tutorial >thinkphp email verification

thinkphp email verification

不言
不言Original
2018-05-10 09:08:173201browse

This article mainly introduces about thinkphp email verification, which has certain reference value. Now I share it with everyone. Friends in need can refer to it

Configuration file: 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格式邮件

ControllerController:

1.Sent successfully

    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;;
        }
     }

Front-end 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>


Related recommendations:

ThinkPHP mailbox class, use the mailbox to retrieve passwords and send mass emails to registered users

The above is the detailed content of thinkphp email verification. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php write fileNext article:php write file