How can I use PHPMailer to send emails ??, Phpmailer email

Source: Internet
Author: User

How can I use PHPMailer to send emails ??, Phpmailer email

Source: http://www.ido321.com/1103.html

Sending emails is a common function. LZ also encountered this feature in the project today.

First, download PHPMailer.

1. https://github.com/dwqs/PHPMailer

2. http://download.csdn.net/detail/u011043843/8063583

After the download, decompress the file to the corresponding location of the project directory and set the class. phpmailer. php and class. smtp. introduce php to the project and check the Code: (do not delete the decompressed file; otherwise, it will not work)

<? Php // import require ("class. phpmailer. php "); require (" class. smtp. php "); date_default_timezone_set ('Asia/Shanghai'); // set the time zone GMT + $ mail = new PHPMailer (); // create a mail sending class $ address =" 15602277510@163.com "; $ mail-> IsSMTP (); // use SMTP to send $ mail-> CharSet = "UTF-8"; // set the encoding, otherwise, send Chinese garbled characters $ mail-> Host = "smtp.qq.com"; // your enterprise Post Office domain name $ mail-> SMTPAuth = true; // enable SMTP authentication $ mail-> Username = "461147874@qq.com"; // Post Office Username (complete email address, please) $ mai L-> Password = "**********"; // post office Password $ mail-> From = "461147874@qq.com "; // sender email address $ mail-> FromName = "dwqs"; $ mail-> AddAddress ($ address, "dwqs"); // recipient address, you can replace it with any email address in the format of AddAddress ("recipient email", "Recipient Name") // $ mail-> AddReplyTo ("",""); // $ mail-> AddAttachment ("/var/tmp/file.tar.gz"); // Add attachments // $ mail-> IsHTML (true ); // set email format to HTML // use HTML format $ mail-> Subject = "verify email"; // mail title $ mail-> Body = "H Ello, This is the test mail "; // the mail content $ mail-> AltBody =" This is the body in plain text for non-HTML mail clients "; // additional information, if (! $ Mail-> Send () {echo 'mailer Error: '. $ mail-> ErrorInfo;} else {echo "Message sent! Congratulations, the email is sent successfully! ";}?>

Test results:


Next article: How many regrets does your university have?


How do I configure phpmailer to send emails locally?
How to Use Phpmailer to receive emails-Technical Q &

Can you share it with me now? O (∩ _ ∩) O Thank you! 100,000 in a hurry !!!
 

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.