PHPmailer mail _ PHP Tutorial

Source: Internet
Author: User
PHPmailer email sending. You want to send a PHP mailer email.

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! ";
}
?>

Http://www.bkjia.com/PHPjc/993867.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/993867.htmlTechArticlePHP mailer mail sent first download class library phpmailer because the load is smtp.163.php so the sender's mailbox to use 163 mailbox its mailbox without other class library import, my attachment .xls is you want...

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.