This article illustrates the method of thinkphp to realize the function of sending the password back to the mail. Share to everyone for your reference. The implementation methods are as follows:
First download the mail.class.php class file, which defines the following parameters in the configuration file:
Copy Code code as follows:
' Mail_address ' => ' ivzhu@qq.com ',//email address
' Mail_smtp ' => ' smtp.qq.com ',//mailbox SMTP Server
' Mail_loginname ' => ' mail@qq.com ',//e-Mail login account
' Mail_password ' => ' 123456 ',//e-mail password
' Mail_charset ' => ' UTF-8 ',//coding
' Mail_auth ' => true,//e-mail authentication
' mail_html ' => true,//true HTML format false txt
In the TP project ORG, put mail.class.php, when used to introduce import (' @.org.mail ');
Copy Code code as follows:
Public Function index () {
Import (' @.org.mail ');
SendMail (' admin@waikucms.com ', ' Mail title ', ' Message body ', ' crooked cool CMS Administrator ');
EXPLANATION parameter: Parameter 1---target mailbox, parameter 2----message header, parameter three--message body, parameter four---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 header ', $content, ' unphp ')) {
Echo ' Chengong ';
}else{
Echo ' Shibai ';
}
$this->display ();
}
Another page accepts parameter res:
Copy Code code as follows:
Public Function index () {
Header ("content-type:text/html; Charset=utf-8 ");
$res =i (' res ');
Echo $res;
if (session ($res) = = $res) {
Echo ' Password back to success ';
session ($res, NULL);
}else{
Echo ' has expired ';
}
}
I hope this article will be helpful to everyone's thinkphp framework program design.