PhpMailer usage-PHP source code

Source: Internet
Author: User
Ec (2); & nbsp; email sending is a frequently used function, but php's default support is not very good. Here we will introduce a good open-source module: phpmailer, this module provides comprehensive functions and supports SMTP verification. The following describes how to use it: 1. Download The phpmailer module: & nbsp; official website www. phpdoc. org2 decompress to a folder 3. The php file contains require script ec (2) and script

Sending mail is a frequently used function, but php does not support it well by default. Here we will introduce a good open-source module: phpmailer, which provides comprehensive functions and supports SMTP verification. The following describes how to use it:

1 download phpmailer module: Official Website http://www.phpdoc.org/

2. decompress the package to a folder.

3. The php file contains require_once ("class. phpmailer. php ");

4. Use SMTP to send Emails:

$ Mail = new PHPMailer (); // get a PHPMailer instance

$ Mail-> CharSet = "gb2312"; // sets the gb2312 Chinese encoding.
$ Mail-> IsSMTP (); // you can use SMTP to send emails.
$ Mail-> Host = "192.168.1.27"; // set the email server address
$ Mail-> Port = 25; // set the mail server Port. The default value is 25.

$ Mail-> From = "mailFrom@tencent.com"; // set the sender's email address
$ Mail-> FromName = "samzhang"; // you can specify the sender's name.
// $ Mail-> SMTPAuth = true; // sets whether password verification is required for SMTP. true indicates that password verification is required.

$ Mail-> Username = "samzhang ";

$ Mail-> Password = ''your password ";
$ Mail-> Subject = $ subject; // you can specify the mail title.

$ Mail-> AltBody = "text/html"; // optional, comment out and test


$ Mail-> Body = "your email content ";

$ Mail-> IsHTML (</

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.