Rumah >pembangunan bahagian belakang >tutorial php >PHPMailer 出错 Could not instantiate mail function
PHPMailer 报错 Could not instantiate mail function.
我在phpmailer官网下载的最新的库,根据里面自带的test下的测试文件配置的,php.ini里面也支持sockets。上网查了许多资料也都试了还是不行,故在此请教各位大神指点指点,不胜感激!!!
<?php<br />/**<br />* Simple example script using PHPMailer with exceptions enabled<br />* @package phpmailer<br />* @version $Id$<br />*/<br /><br />require '../class.phpmailer.php';<br /><br />try {<br /> $mail = new PHPMailer(true); //New instance, with exceptions enabled<br /><br /> $body = file_get_contents('contents.html');<br /> $body = preg_replace('/\\\\/','', $body); //Strip backslashes<br /><br /> $mail->IsSMTP(); // tell the class to use SMTP<br /> $mail->SMTPAuth = true; // enable SMTP authentication<br /> $mail->Port = 25; // set the SMTP server port<br /> $mail->Host = "smtp.163.com"; // SMTP server<br /> $mail->Username = "[email protected]"; // SMTP server username<br /> $mail->Password = "***"; // SMTP server password<br /><br /> //$mail->IsSendmail(); // tell the class to use Sendmail<br /><br /> $mail->AddReplyTo("[email protected]","First Last");<br /><br /> $mail->From = "[email protected]";<br /> $mail->FromName = "phpmailer";<br /><br /> $to = "[email protected]";<br /><br /> $mail->AddAddress($to);<br /><br /> $mail->Subject = "First PHPMailer Message";<br /><br /> $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test<br /> $mail->WordWrap = 80; // set word wrap<br /><br /> $mail->MsgHTML($body);<br /><br /> $mail->IsHTML(true); // send as HTML<br /><br /> $mail->Send();<br /> echo 'Message has been sent.';<br />} catch (phpmailerException $e) {<br /> echo $e->errorMessage();<br />}<br />?>