Home  >  Article  >  Backend Development  >  Thinkphp implements an example of the password retrieval function for sending emails, thinkphp password retrieval_PHP tutorial

Thinkphp implements an example of the password retrieval function for sending emails, thinkphp password retrieval_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:12:28848browse

thinkphp realizes the example of sending email password retrieval function, thinkphp password retrieval

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:

Copy code The code is as follows:
'MAIL_ADDRESS' => 'ivzhu@qq.com', // Email address
'MAIL_SMTP' => 'smtp.qq.com', // Email SMTP server
'MAIL_LOGINNAME' => 'mail@qq.com', // Email login account
'MAIL_PASSWORD' => '123456', // Email password
'MAIL_CHARSET' => 'UTF-8', // Encoding
'MAIL_AUTH' => true, // Email authentication
'MAIL_HTML' => true, // true HTML format false TXT format

Put mail.class.php in tp project org, and introduce import('@.ORG.Mail');
when using it
Copy code The code is as follows:
public function index(){
Import('@.ORG.Mail');
//SendMail('admin@waikucms.com','Email Title','Email Text','WaikkuCMS Administrator');
//Explain the parameters: Parameter 1---Destination mailbox, Parameter 2--Email title, Parameter 3--Email text, Parameter 4---Sender name;
$content=md5(time());
session($content,$content);
$content=C('localurl').'/index.php'.U('Mail/index',array('res'=>$content));
If(SendMail('aa@qq.com','nihao mail title',$content,'unphp')){
echo 'chengong';
}else{
echo 'shibai';
}  
$this->display();
}

Another page accepts parameter res:
Copy code The code is as follows:
public function index(){
header("Content-type: text/html; charset=utf-8");
$res=I('res');
echo $res;
if(session($res)==$res){
echo 'Password retrieved successfully';
session($res,null);
}else{
echo 'has expired';
}
}

I hope this article will be helpful to everyone’s ThinkPHP framework programming.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/920623.htmlTechArticlethinkphp realizes the function of retrieving the password for sending emails, thinkphp password retrieval. This article tells the example of thinkphp realizing the password retrieval for sending emails. Method to return function. Share it with everyone for your reference. ...
Statement:
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