我一直在試圖弄清楚如何讓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