我一直在试图弄清楚如何让phpMailer
在过去的几个小时内工作。我不断收到错误。这里是我的代码:PHPMailer SMTP连接错误
<?php
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "******@gmail.com"; // SMTP username
$mail->Password = "******"; // SMTP password
$host = "smtp.mandrillapp.com";
$port = 587;
$mail->SMTPSecure = 'ssl';
$mail->SMTPDebug = 1;
$webmaster_email = "****@gmail.com"; //Reply to this email ID
$email= $email; // Recipients email ID
$name= $name; // Recipient's name
$mail->From = $webmaster_email;
$mail->FromName = "University of Life Experiences";
$mail->AddAddress($email,$name);
$mail->AddReplyTo($webmaster_email,"Webmaster");
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = "ULE";
$mail->Body = $message; //HTML Body
$mail->AltBody = $message; //Text Body
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
这里是我已经收到了错误:
SMTP ERROR: Failed to connect to server: (0) SMTP connect() failed. Mailer Error: SMTP connect() failed.
我已经尝试了许多不同的SMTP服务器包括Gmail,我总是得到有关无法连接一个类似的错误。
请帮忙,我已经尝试了很多其他phpMailer
示例代码都具有相同的问题。如果任何人都可以推荐任何其他有用的PHP邮件程序。我不使用内置mail()
功能的原因。
你打算从localhost使用这些smtp吗? – Goikiu
即使使用'SMTPDebug = 1',这就是*所有*信息? –
您使用托管的网络服务器吗?也许防火墙阻止端口25.如果你可以通过SSH连接,请尝试'telnet你服务器smtp'并看看会发生什么。 – Jens