【发布时间】:2015-05-17 19:57:58
【问题描述】:
<?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 连接()失败
当我尝试运行 PHP 文件时。请帮我解决错误。为了得到错误,我可能做了哪些错误的事情以及如何解决这个问题?
【问题讨论】:
-
请在发布此问题的另一个副本之前搜索答案。
-
在我的情况下没有一个答案有效。这就是为什么我发布了一个问题,询问任何其他解决方案。
-
我对您阅读all 877 duplicates 并没有尝试或提及他们建议的任何内容印象深刻。在这种情况下,Ariel 的建议将毫无用处,因为您已经尝试了所有这些。