Phpmailer use Method (Support mass):

Source: Internet
Author: User
Tags email account

First, download the function package

Address: Https://github.com/PHPMailer/PHPMailer

Second, the test server environment

Use the Phpinfo () function to print out whether sockets is supported (the socket is part of the PHP extension), and if "enable" indicates environmental support.

Third, extract the extracted files

Unzip the downloaded Phpmailer-master.zip package and extract the following files

class.phpmailer.php

class.pop3.php

class.smtp.php

phpmailerautoload.php

Four, write Send mail demo, can be extracted as tool class

The detailed code is as follows:

   Public functionSendMail () {require_once(Vendor_path. " Phpmailer/phpmailerautoload.php "); $mail=New\phpmailer;// Create a Phpmailer instance        $mail->ISSMTP ();//send using SMTP mode        $mail->charset = "UTF-8";// set encoding, otherwise send Chinese garbled        $mail->host = "smtp.qq.com";// The host IP that needs to send mail, the following is the QQ host server        $mail->smtpauth =true;//enable the SMTP authentication feature        $mail->username = "[email protected]";// Sender Email Account        $mail->password = "Xxxxxxxxxx";// Sender's mailbox password, QQ mailbox generated authorization code, QQ mailbox need to open IMAP/SMTP service        $mail->setfrom (' [email protected] ', ' sender name ');// Set Sender information (parameter 1: Sender's mailbox, Parameter 2: Sender name)        $mail->addaddress (' [email protected] ', ' Recipient name ');// Recipient Mailbox----Note If this is a mass, pity Dorado for loop add recipient mailbox        $mail->subject = ' Sub-geumcheon ';// subject of the message, which is the title        $mail->body = ' Green Anthony, leisurely I think, longitudinal I do not go, Zinning not come. Pick Xi da Xi, in the city Que Xi, a day, such as March XI. ‘;//Message Content        $mail->altbody = ' message attachment information ';// message attachment information, can be omitted        $mail-WordWrap= 50;// Line break, how many characters per line are wrapped automatically//$mail->ishtml (TRUE); Whether to send HTML        if(!$mail->send ()) {// Send mail            Echo"Mailer Error:".$mail-errorinfo; } Else {            Echo"Sent successfully!"; }

It is recommended to send content in HTML format. You can use the <BR \> line break Note: If you are developing a mail message in text format, the "\ n", "\ r \ n" line breaks do not take effect, only the set wordwrap specifies the number of characters per line

Reprint please indicate source: Research and development, this article link: http://www.yanfadi.com/article/4.html

Phpmailer use Method (Support mass):

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.