这篇文章主要介绍了关于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>
相关推荐:
立即学习“PHP免费学习笔记(深入)”;
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号