SMTP Error: Could not connect to SMTP host. Message could not be sent.无法连接到SMTP主机
Mailer Error: SMTP Error: Could not connect to SMTP host.
我似乎无法找到一种方法,使CentOS的下PHPMailer的工作。 Mail在XAMPP下的Windows下工作得很好,但是我总是在Linux下得到这个错误。
SMTP服务器是监听端口25的Lotus Domino,CentOS机器根本没有防火墙,奇怪的是即使邮件()也不起作用。它什么也没有返回(在Windows上返回1)。如果我通过CentOS服务器通过telnet发送邮件,它工作得很好,所以我不认为这是一个网络问题。它必须与PHP相关,但我不知道如何。
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "192.168.x.x";
$mail->SMTPAuth = false;
$mail->From = "[email protected]";
$mail->FromName = "XXX";
$mail->AddAddress("[email protected]");
$mail->IsHTML(true);
$mail->Subject = "Test";
$mail->Body = "Test";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
只是为了澄清上面的代码工作在XAMPP(Windows)中。
我调试的PHPMailer的错误和错误发生在这里(class.smtp.php方法连接()):
$this->smtp_conn = @fsockopen($host, // the host of the server
$port, // the port to use
$errno, // error number if any
$errstr, // error message if any
$tval); // give up after ? secs
// verify we connected properly
if(empty($this->smtp_conn)) {
$this->error = array("error" => "Failed to connect to server",
"errno" => $errno,
"errstr" => $errstr);
if($this->do_debug >= 1) {
echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
}
return false;
}
看起来它无法打开插座...
更新:使用$ mail-> SMTPDebug = 2;阿尔瓦罗的建议产生这样的输出:
SMTP -> ERROR: Failed to connect to server: Permission denied (13)
您是否试过指定登录凭据? –
没有。这是什么意思?你的意思是把它们设置为“”? – raz3r
FYI tryed '$ mail-> SMTPAuth = true; $ mail-> Username =“”; $ mail-> Password =“”;' 刚才,没有运气。 – raz3r