This article uses thinkphp version 2.1 and Phpmailer 5.1. (The latter recommends that you download it directly from this blog, as we cannot guarantee that the following code will work in all versions of Phpmailer)
Here are the specific steps:
First step, add Phpmailer class Library
Phpmailer Mail Send class V5.1 download address
Unzip the downloaded file and move the Phpmail directory to the vendor within the thinkphp directory. (Make sure the class.phpmailer.php file is ThinkPHPVendorPHPMailerclass.phpmailer.php)
Step two, add the Send mail function
Add the following code to the common.php file (if not created) in the common folder in the project directory:
< span="">< span="">
< span="">
< span="">< span="">
SendMail (,,' Phpmailer.class#phpmailer '=-->charset= ' UTF-8 '->addaddress (->body=->from=c (' mail_address '
->fromname= ' lilyrecruit '
->subject=
->host=c (' mail_smtp '
->smtpauth=
->username=c (' Mail_loginname '
-> Password=c (' Mail_password '
( ->?>
< span="">
Edit the config.php in the Conf directory and add the following to the return array
< span="">< span="">< span="">< span="">< span="">< span="">< span="">< span="">
< em="">
< em="">Fourth step, send mail in action
Since thinkphp will automatically load functions in common.php, it is only necessary to use the following code when sending a message.
SendMail ("xxx@xxx.com", "Mail Header", "message body");
At this point, this tutorial has ended. Sprinkle flower ~ ~ ~
Welcome to successfully configure the classmate SendMail ("dreamrunner@foxmail.com", "I will also use thinkphp send mail", "Blah blah ~ ~");
There are some notes
What if I need to wrap the message body? In fact, the simplest way is--
SendMail ("xxx@xxx.com", "Mail Header", "message body
I'll change the line, ~~!. ");
QQ mailbox (including Foxmail) and NetEase's 126, 163 are tested successfully. Because the recent visit Gmail is difficult, so there is no test. I heard that Gmail requirements must use SSL, there is the need for students to Google Baidu Phpmailer method.
< em="">http://www.bkjia.com/PHPjc/440114.html www.bkjia.com true http://www.bkjia.com/PHPjc/440114.html techarticle This article uses thinkphp version 2.1 and Phpmailer 5.1. (The latter recommends that you download it directly from this blog, as we cannot guarantee that the following code will work in all versions of Phpmailer .)
< em="">