Php sends emails

Source: Internet
Author: User
The following is the test File: & lt ;? Phprequire (& quot; class. phpmailer. php & quot;); // the downloaded file must be placed in the directory where the file is located $ mailnewPHPMailer (); // create an email sending class $ address & quot; email address of the recipient & quot; // email address of the recipient...

The following is the test file:

Require ("class. phpmailer. php"); // the downloaded file must be in the directory where the file is located.
$ Mail = new PHPMailer (); // Create a mail sending class
$ Address = "email address of the recipient"; // email address of the recipient
$ Mail-> IsSMTP (); // send using SMTP
$ Mail-> Host = "smtp.qq.com"; // your enterprise Post Office domain name
$ Mail-> SMTPAuth = true; // enable SMTP verification

// The following $ mail-> Username, $ mail-> Password, $ mail-> From is required
$ Mail-> Username = "address of the user who sent the email"; // address of the user who sent the email
$ Mail-> Password = "Password of the user who sent the email"; // Password of the user who sent the email
$ Mail-> Port = 25;
$ Mail-> From = "email address of the user who sent the mail"; // email address of the mail sender


// $ Mail-> FromName = "10-php ";
$ Mail-> AddAddress ("$ address", 'recipient names can be dispensable '); // recipient address, which can be replaced with any email box to receive emails, the format is AddAddress ("recipient email", "recipient name ")
// $ Mail-> AddReplyTo ("", ""); www.2cto.com

// $ Mail-> AddAttachment ("/var/tmp/file.tar.gz"); // add an attachment
// $ Mail-> IsHTML (true); // set email format to HTML // whether HTML format is used
 
$ Mail-> Subject = "PHPMailer test mail"; // mail title
$ Mail-> Body = "Hello, this is the test mail"; // The mail content
$ Mail-> AltBody = "This is the body in plain text for non-HTML mail clients"; // additional information, which can be omitted
If (! $ Mail-> Send ())
{
Echo "failed to send the email.

";
Echo "error cause:". $ mail-> ErrorInfo;
Exit;
}

Echo "email sent successfully ";

 

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.