thinkphp发送邮件密码找回功能
首先下载mail.class.php类文件,配置文件中定义下列参数:
'MAIL_ADDRESS' => 'ivzhu@qq.com' , // 邮箱地址 'MAIL_SMTP' => 'smtp.qq.com' , // 邮箱SMTP服务器 'MAIL_LOGINNAME' => 'mail@qq.com' , // 邮箱登录帐号 'MAIL_PASSWORD' => '123456' , // 邮箱密码 'MAIL_CHARSET' => 'UTF-8' , // 编码 'MAIL_AUTH' => true, // 邮箱认证 'MAIL_HTML' => true, // true HTML格式 false TXT格式在tp项目org中放入mail.class.php,使用时候引入 import('@.ORG.Mail');
public function index(){ import( '@.ORG.Mail' ); //SendMail('admin@waikucms.com','邮件标题','邮件正文','歪酷CMS管理员'); //解释下参数: 参数1---目标邮箱, 参数2----邮件标题,参数三--邮件正文,参数四---发件人名称; $content =md5(time()); session( $content , $content ); $content =C( 'localurl' ). '/index.php' .U( 'Mail/index' , array ( 'res' => $content )); if (SendMail( 'aa@qq.com' , 'nihao邮件标题' , $content , 'unphp' )){ echo 'chengong' ; } else { echo 'shibai' ; } $this ->display(); }另一个页面接受参数res:
public function index(){ header( "Content-type: text/html; charset=utf-8" ); $res =I( 'res' ); echo $res ; if (session( $res )== $res ){ echo '密码找回成功' ; session( $res ,null); } else { echo '已经过期' ; } }查看更多关于thinkphp发送邮件密码找回功能 - Thinkphp的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did6255