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...