这个问题已经在这里有了答案:

<?php

require 'PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = 'smtp';
$mail->SMTPAuth = true;
$mail->Host = 'smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
// or try these settings (worked on XAMPP and WAMP):
// $mail->Port = 587;
// $mail->SMTPSecure = 'tls';


$mail->Username = "vignesh*****@gmail.com";
$mail->Password = "**********";

$mail->IsHTML(true); // if you are going to send HTML formatted emails
$mail->SingleTo = true; // if you want to send a same email to multiple users. multiple emails will be sent one-by-one.

$mail->From = "vignesh*******@gmail.com";
$mail->FromName = "vignesh";

$mail->addAddress("vigneshanandakumar@gmail.com","User 1");
/*$mail->addAddress("user.2@gmail.com","User 2");

$mail->addCC("user.3@ymail.com","User 3");
$mail->addBCC("user.4@in.com","User 4");*/

$mail->Subject = "Testing PHPMailer with localhost";
$mail->Body = "Hi,<br /><br />This system is working perfectly.";

if(!$mail->Send())
    echo "Message was not sent <br />PHPMailer Error: " . $mail->ErrorInfo;
else
    echo "Message has been sent";
    ?>

我得到了

消息未发送
PHPMailer错误:SMTP connect()失败

当我尝试运行PHP文件时。 请帮助我解决错误。 我为获取错误而可能做错了什么以及如何解决此问题?

===============>>#1 票数:2 已采纳

发生这种情况的原因有很多,这里有一个文档,可以帮助您解决这些问题PHPMailer解决连接问题

  ask by Vignesh Anandakumar translate from so

未解决问题?本站智能推荐: