thinkphp implementation _php instance of sending mail password retrieve function instance

Source: Internet
Author: User
Tags php class

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.