Use Phpmailer in PHP to send mail using QQ mailbox

Source: Internet
Author: User
Tags server port ssl connection

1     /**2 * Place order to send mail3 * @to recipient @title Title @content content4      */5     functionSendMail ($to,$title,$content){6 7                //introducing Phpmailer Core files using require_once contains warnings to avoid duplicate definitions of Phpmailer classes8         require_once(".. /.. /includes/phpmailer/5.1/class.phpmailer.php ");9         require_once(".. /.. /includes/phpmailer/5.1/class.smtp.php ");Ten                //Instantiate Phpmailer Core class One         $mail=NewPhpmailer (); A                //whether to enable debug for SMTP debugging development environment It is recommended to turn on the production environment comment off to turn debug debug mode off by default -         $mail->smtpdebug = 1; -                 //send mail using SMTP authentication the         $mail-issmtp (); -                 //Set login authentication using SSL encryption -         $mail->smtpsecure = ' SSL '; -                 //SMTP needs authentication This must be true +         $mail->smtpauth =true; -                 //the server address of the link QQ domain mailbox + //$mail->host = ' '; A         $mail->host = ' '; at                //Set login authentication using SSL encryption -         $mail->smtpsecure = ' SSL '; -                 //set the SSL connection to the SMTP server's remote server port number, the previous default is 25, but now the new one seems to be unavailable optional 465 or 587 -         $mail->port = 465; -                  //set SMTP Helo message header This optional content is arbitrary - //$mail->helo = ' Hello Server '; in //Set sender's host domain optional default to localhost content arbitrary, recommended to use your domain name -         $mail->hostname = ' localhost '; to                 //set the encoding of sent messages optional GB2312 I like utf-8. UTF8 is said to be garbled in some client's inbox. +         $mail->charset = ' UTF-8 '; -                 //Set the sender's name (nickname) any content that displays the sender's name before the sender 's e-mail address of the recipient's message the         $mail->fromname = ' Don put new buy '; *                 //SMTP login account here to fill in the string format QQ number can be $         $mail->username = ' 123456 ';Panax Notoginseng                 //The SMTP login password uses the generated authorization code (just the latest authorization code that you saved) -         $mail->password = ' 20170425 '; the                 //set the sender's e-mail address here fill in the "sender's mailbox" mentioned above +         $mail->from = ' [email protected] '; A                //whether the message body is HTML-encoded note here is a method that is no longer a property of true or false the         $mail->ishtml (true); +                //to set a recipient's mailbox address this method has two parameters the first parameter is the recipient's mailbox address the second parameter is a nickname that is set to that address. The second parameter has a small meaning. -         $mail->addaddress ($to, ‘‘); $                //adding multiple recipients calls the method multiple times $         $mail->addaddress (' [email protected] ', '); -         $mail->addaddress (' [email protected] ', '); -         $mail->addaddress (' [email protected] ', '); the         $mail->addaddress (' [email protected] ', '); -                 //Add the subject of the messageWuyi         $mail->subject =$title; the                 //adding ishtml to true on top of the message body can be a complete HTML string such as: Use the file_get_contents function to read the local HTML file -         $mail->body =$content; Wu                 //add an attachment to the message the method also has two parameters the first parameter is the directory where the attachment is stored (either relative to the directory, or absolute directory) The second parameter is the name of the attachment in the message attachment - //$mail->addattachment ('./d.jpg ', ' mm.jpg '); About //The same method can be multiple calls to upload more than one attachment $ //$mail->addattachment ('./jlib-1.1.0.js ', ' jlib.js '); -         $mail-send (); -                //simple judgment and prompt information -           if($status) { A             return true; +}Else { the             return false; -         } $     } the  the 
1 // call method to send mail 2 $this->sendmail (' [email protected] ', ' You have a new order ', ' Administrator, you have a new online payment order waiting to be processed and the order number is '.  $order _sn);

Use Phpmailer in PHP to send mail using QQ mailbox

Related Article

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: 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.