thinkphp实现发送邮件密码找回功能实例
作者:shichen2014 时间:2024-05-02 17:16:54
本文实例讲述了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,邮件
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
jupyter notebook的安装与使用详解
2022-09-11 23:35:25
![](https://img.aspxhome.com/file/2023/7/120477_0s.png)
python字典的setdefault的巧妙用法
2021-05-18 02:58:48
Django中ajax发送post请求 报403错误CSRF验证失败解决方案
2021-06-11 19:47:32
![](https://img.aspxhome.com/file/2023/0/80580_0s.png)
Python迭代器iterator生成器generator使用解析
2023-11-17 18:50:24
谈一谈bootstrap响应式布局
2023-08-22 20:17:39
![](https://img.aspxhome.com/file/2023/3/56053_0s.png)
js创建一个input数组并绑定click事件的方法
2023-08-15 02:35:09
Python中的Function定义方法第1/2页
2021-05-10 20:33:49
MySQL模式 Strict Mode知识点详解
2024-01-27 20:50:41
python开发中两个list之间传值示例
2022-06-07 03:44:54
![](https://img.aspxhome.com/file/2023/7/87877_0s.jpg)
python GUI库图形界面开发之PyQt5树形结构控件QTreeWidget详细使用方法与实例
2023-04-12 03:34:40
![](https://img.aspxhome.com/file/2023/4/115744_0s.png)
mysql存数组的实例代码和方法
2024-01-23 22:45:21
Mysql自动备份与还原方法
2024-01-15 03:19:32
Python实现HTTP协议下的文件下载方法总结
2023-04-29 20:01:36
Go标准容器之Ring的使用说明
2023-09-21 02:18:14
ECharts设置x轴刻度间隔的2种解决方法
2023-08-28 04:18:38
![](https://img.aspxhome.com/file/2023/1/56141_0s.png)
Python requests的SSL证书验证方式
2021-10-06 09:21:51
![](https://img.aspxhome.com/file/2023/8/118058_0s.png)
MySQL数据库备份以及常用备份工具集合
2024-01-23 04:25:53
Python实现公历(阳历)转农历(阴历)的方法示例
2021-08-02 09:54:44
![](https://img.aspxhome.com/file/2023/0/77750_0s.png)
Pyqt清空某一个QTreeewidgetItem下的所有分支方法
2022-01-24 10:29:46
SQL Server 2000如何设置会话上下文信息?
2010-05-18 18:33:00