PHP mailer email sending

Source: Internet
Author: User

PHP mailer email sending

First, download the class library phpmailer. Because smtp.163.php is loaded, the sender's email address must use the 163 email address, its inbox, and other similar libraries. My attachment. xls is the attachment you want to add, which can be of any type.

Echo"

";
Require_once ('class. phpmailer. php ');


$ Mail = new PHPMailer (); // instantiate
$ Mail-> IsSMTP (); // enable SMTP
$ Mail-> Host = "smtp.163.com"; // The SMTP server uses the 163 email address as an example.
$ Mail-> Port = 25; // mail sending Port
$ Mail-> SMTPAuth = true; // enable SMTP authentication


$ Mail-> CharSet = "UTF-8"; // Character Set
$ Mail-> Encoding = "base64"; // Encoding method


$ Mail-> Username = "yourmail@163.com"; // your mailbox 163
$ Mail-> Password = "password"; // your Password
$ Mail-> Subject = "hello"; // any email title


$ Mail-> From = "youradmin@163.com"; // sender address (that is, your mailbox)
$ Mail-> FromName = "name"; // any sender name


$ Address = "$ _ POST ['email ']"; // the recipient's email is from post. This is the recipient's email.
$ Mail-> AddAddress ($ address, ""); // Add a recipient (address, nickname)


$ Mail-> addattachment('xx.xls', 'My attachment .xls '); // Add the attachment and specify the name
$ Mail-> IsHTML (true); // html content is supported
$ Mail-> AddEmbeddedImage ("logo.jpg", "my-attach", "logo.jpg"); // you can specify an image in the email.
$ Mail-> Body = 'hello, Friend!
This is an email from helloweba.com!
'; // Subject content


// Send
If (! $ Mail-> Send ()){
Echo "failed to send:". $ mail-> ErrorInfo;
} Else {
Echo "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.