配置文件: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邮箱验证的详细内容。
