Home > Backend Development > PHP Tutorial > Introduction to thinkphp's function of retrieving passwords for sending emails

Introduction to thinkphp's function of retrieving passwords for sending emails

不言
Release: 2023-04-02 09:08:02
Original
1891 people have browsed it

This article mainly introduces the method of thinkphp to realize the password retrieval function of sending emails. It details the implementation method of configuration files and function codes in the form of examples. It is a very practical skill. Friends who need it can refer to it

The example in this article describes how thinkphp implements the password retrieval function for sending emails. Share it with everyone for your reference. The specific implementation method is as follows:

First download the mail.class.php class file, and define the following parameters in the configuration file:

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

Put mail.class.php in the tp project org, when using it Introduce 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();  
}
Copy after login

Another page accepts parameters 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 '已经过期';  
}  
}
Copy after login

The above is the entire content of this article, I hope it will be helpful to everyone Learning is helpful. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to implement 2 paging on a page in thinkphp

PHP implements the reflection of images Color processing function php skills

The above is the detailed content of Introduction to thinkphp's function of retrieving passwords for sending emails. For more information, please follow other related articles on the PHP Chinese website!

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