Example of using PHPMailer to send emails

Source: Internet
Author: User
In php, we have installed the mail component on the linux server and can directly use the mail function to send emails. for windows systems, we mostly use PHPMailer to send emails. here is a simple example. use PHPMailer... in php, we have installed the mail component on the linux server and can directly use the mail function to send emails. for windows systems, we mostly use PHPMailer to send emails. here is a simple example.

Use the PHPMailer class to send emails. the code is as follows:

$ Phpmailer = new PHPMailer (); $ phpmailer-> IsSMTP (); // use the smtp protocol to send $ phpmailer-> Host = 'smtp .163.com '; $ phpmailer-> SMTPAuth = true; $ phpmailer-> Username = '******'; // 163 email account @ the $ phpmailer-> Password = '*******' in front of @ 163 '******'; // password // $ phpmailer-> From = '***** @ 163.com'; // email address $ phpmailer-> FromName = 'yanjiadong '; $ phpmailer-> Subject = 'Welcome to register, your activation mail'; $ phpmailer-> Body = 'click to activate'; // Add the recipient $ phpmailer-> Add Address ('********* @ qq.com', 'Username'); // send an echo $ phpmailer-> send ()? 'OK': 'fail ';

Note that you can search for phpmailer components by Baidu.

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.