我有以下代码给出和错误
<?php
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer(true);
$mail->IsSendmail();
//Send mail using gmail
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "myemail@gmail.com"; // GMAIL username
$mail->Password = "mypassword"; // GMAIL password
$mail->From = "myemail@gmail.com";
$mail->FromName = "Online Request";
$mail->AddAddress("receiver_email@gmail.com","myself");
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
错误是
致命错误:未捕获的异常&#39; phpmailerException&#39;邮件&#39; SMTP connect()失败。&#39;在C:\ Softwares \ xampp \ htdocs \ email_testing \ phpmailer \ class.phpmailer.php:1193
堆栈追踪:
0 C:\ Softwares \ xampp \ htdocs \ email_testing \ phpmailer \ class.phpmailer.php(1036):PHPMailer-&gt; smtpSend(&#39; Date:Thu,31 J ...&#39;, &#39; - b1_02dd62dba5 ...&#39)
1 C:\ Softwares \ xampp \ htdocs \ email_testing \ phpmailer \ class.phpmailer.php(943):PHPMailer-&gt; postSend()#2 C:\ Softwares \ xampp \ htdocs \ email_testing \ test.php( 25):PHPMailer-&gt; send()
3 {main}在1193行的C:\ Softwares \ xampp \ htdocs \ email_testing \ phpmailer \ class.phpmailer.php中抛出
我正在使用xamp和php 5.3.8,apache 2.2.2.1,xamp ver 1.7.7
任何想法?感谢帮助