doubi8512 2014-04-04 17:11 采纳率: 0%
浏览 57

PHPMailer在Windows上引发隐秘异常

I have the following code snippet in my php script:

$mail = new PHPMailer(true);               
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->UserName = 'myemailaddress@gmail.com';
$mail->Password = 'XXX';
$mail->Subject = 'TEST';        
$mail->MsgHTML($msg);       
$mail->AddAddress('test@gmail.com','Test User');
$mail->SetFrom("sitemanager@mysite.com","My User");
if(!$mail->Send()){
    echo "Mailer Error: " . $mail->ErrorInfo;
}else{
    echo "Message has been sent";
}    

The $mail->Send() method never finishes executing so no error is returned but debugging with php I get the following in my browser debugging console:

<b>Fatal error</b>:  Uncaught exception 'phpmailerException' with message 'Could not instantiate mail function.' in ...\data\phpmailer\class.phpmailer.php:779
Stack trace:
#0 ...\data\phpmailer\class.phpmailer.php(662): PHPMailer-&gt;MailSend('Date: Fri, 4 Ap...', '--b1_50a0740efb...')
#1 ...\data\phpmailer\class.phpmailer.php(588): PHPMailer-&gt;PostSend()
#2 ...\data\utils.php(255): PHPMailer-&gt;Send()
#3 ...\data\utils.php(164): emailUploadNotification('ce219bf6-7188-1...', Array, 'ce219bf6-7188-1...')
#4 {main}
  thrown in <b>...\data\phpmailer\class.phpmailer.php</b> on line <b>779</b><br />

I need some help finding out why I cannot send emails from my php script. Thank you.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?