PHP uses the mail class library e-mail method that comes with pear, pear class library _ PHP Tutorial

Source: Internet
Author: User
PHP uses the mail class library e-mail method that comes with pear, pear class library. PHP uses the mail class library e-mail method that comes with pear. the pear class library in this article describes how PHP uses the mail class library e-mail method that comes with pear. Share it with you for your reference. The following describes how to send an email using the mail class library provided by pear in PHP.

This example describes how to send an email using the mail class library that comes with pear in PHP. Share it with you for your reference. The details are as follows:

Here, you can use the mail class library provided by pear to send emails. you can use the pear install command to install the corresponding Library.

Body = "click my new password"; sendMail_smtp ("xxxxxxxx@qq.com", 'test', $ body); function sendMail_smtp ($ smtpemailto, $ mailsubject, $ mailbody) {// error_reporting (7); require_once 'mail. php '; require_once' Mail/mime. php '; $ from = 'admin @ xxx.com'; $ to = $ smtpemailto; $ password = 'xxxx'; $ mail_config = array ("host" => "smtp.ym.163.com ", "port" => 25, "auth" => true, "username" => $ from, "password" => $ password, "from" => $ from ,); $ hdrs = array ('from' => $ From, 'to' => $ To, // recipient address 'subobject' => $ mailsubject ); $ mime = new Mail_mime (); // $ mime-> setTXTBody ($ text); // add an attachment // $ mime-> addHTMLImage('php.gif ', 'image/GIF ', '20140901', true); $ mime-> _ build_params ['HTML _ charset'] = "UTF-8 "; // Set the encoding format $ mime-> _ build_params ['head _ charset'] = "UTF-8"; // Set the encoding format $ mime-> setHTMLBody ($ mailbody ); $ body = $ mime-> get (); $ hdrs = $ mime-> headers ($ hdrs); $ mail = Mail: factory ('smtp ', $ mail_config ); $ succ = $ mail-> send ($ to, $ hdrs, $ body); if (PEAR: isError ($ succ) {// echo 'email sending failed: '. $ succ-> getMessage (); $ err = 'Email sending failed :'. $ succ-> getMessage (); $ content = $. "\ t ". date ('Y-m-d H: I: s '). "\ t ". $ err. "\ r \ n";} else {// $ content = $. "\ t ". date ('Y-m-d H: I: s '). "\ t Email sent succesfully \ r \ n"; return true ;}}

I hope this article will help you with php programming.

The example in this article describes how to send mails using the mail class library that comes with pear in PHP. Share it with you for your reference. The details are as follows...

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.