thinkphp email verification

不言
Release: 2023-03-25 18:26:02
Original
3116 people have browsed it

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格式邮件
Copy after login

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('发送失败');
            }
    }
Copy after login
     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;;
        }
     }
Copy after login

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>
Copy after login


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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!