PHP uses the mail Class Library E-mail method that comes with pear, pear class library
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 = "<a href = 'HTTP: // www.baidu.com/'target = '_ blank'> click I regenerate password </a>"; 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.