2014-08-28 36 views
-2
**Error:**SMTP NOTICE: EOF caught while checking if connected SMTP connect() failed. 
Mailer Error: SMTP connect() failed. 

我的代碼是:我要發使用PHPMailer的電子郵件給錯誤

<?php 
require('class.phpmailer.php'); 
//require_once('class.phpmailer.php'); 
//require_once("inc/phpmailer/class.phpmailer.php"); 
$mail = new PHPMailer();// create a new object 
$mail ->IsSMTP(); // enable SMTP 
$mail ->SMTPDebug = 1; // debugging: 1 = errors and messages, 2        = messages only 
$mail->SMTPAuth = true; // authentication enabled 
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail 
$mail->Host = "smtp.gmail.com"; 
$mail->Port = 587; // or 465 
$mail->IsHTML(true); 
$mail->Username = "[email protected]"; 
$mail->Password = "mudunuru%^&"; 
$mail->SetFrom("[email protected]"); 
$mail->Subject = "Test"; 
$mail->Body = "hello"; 
$mail->AddAddress("[email protected]"); 
print $mail; 
if(!$mail->Send()) { 
    echo "Mailer Error: " . $mail->ErrorInfo; 
} else { 
    echo "Message has been sent"; 
} 

你的幫助將apperaciated

回答

0

這是你的問題:

$mail->SMTPSecure = 'ssl'; 
$mail->Port = 587; 

你是試圖將SSL與非SSL端口進行對話。做到這一點,而不是:

$mail->SMTPSecure = 'tls'; 
$mail->Port = 587; 

我也建議您獲得latest version of PHPMailer和底座上裝有它的實例代碼。

相關問題