PHPMailerAutoload成功消息,但不发送任何电子邮件


PHPMailerAutoload success message,but not sending any emails

我正试图使用gmail-smtp服务器作为php中的中继发送电子邮件。我在webmatrix服务器上编程,我使用PHPMailerAutoload库发送电子邮件。我的操作系统是windows 7 64位。我已经将php.ini配置为使用gmail-smtp服务器。运行代码时,我收到成功消息,但没有发送电子邮件。有人能帮我找到问题吗,谢谢。这是我的部分代码:

     $mail = new PHPMailer(true);
           //Send mail using gmail
           if($send_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 = "example"; // GMAIL username
    $mail->Password = "password"; // GMAIL password
}
//Typical mail data
$mail->AddAddress($email, $name);
$mail->SetFrom("example@gmail.com", "name");
$mail->Subject = "My Subject";
$mail->Body = "Mail contents";
$mail->SMTPDebug = true;
try{
    $mail->Send();
    echo "Success!";
} catch(Exception $e){
    //Something went bad
    echo "Fail - " . $mail->ErrorInfo;
}

下载包装文件PHPMailer,导入如下所示的文件。

 require '../PHPMailer/PHPMailerAutoload.php';
    $mail = new PHPMailer;
       //Send mail using gmail
     if($send_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 = "example"; // GMAIL username
      $mail->Password = "password"; // GMAIL password
    }
 //Typical mail data
    $mail->AddAddress($email, $name);
    $mail->SetFrom("example@gmail.com", "name");
    $mail->Subject = "My Subject";
    $mail->Body = "Mail contents";
    $mail->SMTPDebug = true;
    try{
       $mail->Send();
       echo "Success!";
     } catch(Exception $e){
    //Something went bad
        echo "Fail - " . $mail->ErrorInfo;
     }