thinkphp using Phpmailer to send _php tutorials for mail delivery

Source: Internet
Author: User

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="">
  • 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.