PHPMailer 出错 Could not instantiate mail function

php中文网
发布: 2016-06-13 11:51:17
原创
1647人浏览过

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&#160;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&#160;protected]","First Last");<br /><br />	$mail->From       = "[email&#160;protected]";<br />	$mail->FromName   = "phpmailer";<br /><br />	$to = "[email&#160;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 />?>
登录后复制


------解决方案--------------------
给出你的下载地址

可能是要求的 php 版本太高了吧?
------解决方案--------------------
//$mail->IsSendmail();
这个去掉的话默认是使用系统的mail函数发送邮件的。会不会是这个原因。

豆包AI编程
豆包AI编程

智能代码生成与优化,高效提升开发速度与质量!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号