This article mainly introduces thinkphp's method of realizing the retrieval of the email sending password, and describes in detail the implementation methods of the configuration file and function code in the form of an instance, which is a very practical technique, for more information about how thinkphp can retrieve the email password, see the example in this article. Share it with you 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:
The code is as follows:
'Mail _ address' => 'ivzhu @ qq.com ', // email ADDRESS
'Mail _ SMTP '=> 'smtp .qq.com', // MAIL smtp server
'Mail _ loginname' => 'Mail @ qq.com ', // email logon account
'Mail _ password' => '123', // 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 the tp project org and import ('@. ORG. mail') when using it ');
The code is as follows:
Public function index (){
Import ('@. ORG. mail ');
// SendMail ('admin @ waikucms.com ', 'Email title', 'Email body', 'cool CMS Postmaster ');
// Explain the following parameters: parameter 1 --- target mailbox, parameter 2 ---- Mail title, parameter 3 -- Mail body, 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 email title', $ content, 'unphp ')){
Echo 'chengong ';
} Else {
Echo 'shibai ';
}
$ This-> display ();
}
The other page accepts the parameter res:
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 'expired ';
}
}
I hope this article will help you with ThinkPHP framework programming.