PHP using Phpmailer to send mail sharing method

Source: Internet
Author: User
This article mainly share with you the method that PHP uses phpmailer send mail, hope can help everybody.

Environment: php5.6

Need to import message class package

Preparatory work:

Log in to send the email account, open the Settings center, turn on the SMTP service, set the authorization code
Open Tutorial: https://jingyan.baidu.com/article/fdbd42771da9b0b89e3f48a8.html
When sending a message, the user name is the mailbox account, the password is the authorization code set

//recipient address $address = ' 14321916@qq.com ';//title $subject = ' Test message ';//information $message = '    Content Content Content content content contents '; function Sp_send_email ($address, $subject, $message) {$mail =new \phpmailer ();//Set Phpmailer send with SMTP server email$mail- >ISSMTP (); $mail->ishtml (TRUE);//Set the character encoding of the message, if not specified, ' UTF-8 ' $mail->charset= ' UTF-8 ';//Add the recipient address, You can use it multiple times to add multiple recipients $mail->addaddress ($address);//Set the message body $mail->body= $message;//Set the From field of the message header. $mail->from= ' 15998186418@163.com ';//Set the sender's name $mail->fromname= ' you guess who I am ';//Set the message header $mail->subject= $subject; /Set up an SMTP server. $mail->host= ' smtp.163.com ';//Set the SMTP server port. $mail->port= "25";//Set to "Require authentication" $mail->smtpauth=true;//set user name and password. $mail->username= ' 123456@163.com '; $mail->password= ' 123456 ';//Send mail. $res = $mail->send (); return $res;//Successful return true} 

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.