2014-02-13 24 views
1

我看過類似的線程,但這個問題是不同的。問題是100%同一代碼在同一個類中正在另一個頁面上工作。但由於某些奇怪的原因,它在索引頁上不起作用。這裏是我得到的錯誤:無法轉換PHPMailer類的對象

唯一的區別是工作文件位於/ xyz的根目錄下的子目錄中,但索引文件位於根目錄下,/ /但表單的操作指向子目錄中的文件目錄是/xyz/file.php所以我不認爲這可能是一個問題。

PHP開捕致命錯誤:類的PHPMailer的對象無法在/home4/elliot/public_html/web.com/class.phpmailer.php on line 764

這裏被轉換成字符串就是PHP梅勒顯示在764:

$address = trim($address); 

這裏是工作的代碼如下所示:

date_default_timezone_set('Etc/UTC'); 

require '../PHPMailerAutoload.php'; 

$mail = new PHPMailer(); 

$mail->isSMTP(); 

$mail->SMTPDebug = 0; 

$mail->Debugoutput = 'html'; 

$mail->Host = "removed"; 

$mail->Port = 25; 

$mail->SMTPAuth = true; 

$mail->Username = "removed"; 

$mail->Password = "removed"; 
//Set who the message is to be sent from 
$mail->setFrom('[email protected]', 'John Doe'); 

$mail->addReplyTo('[email protected]', 'John Doe'); 
//Set who the message is to be sent to 
$mail->addAddress($email,$full); 

$mail->Subject = 'Subject'; 
$mail->Body  = $body; 
$mail->IsHTML(true); 
$mail->send(); 

這裏是不工作的代碼如下所示:

date_default_timezone_set('Etc/UTC'); 

require '../PHPMailerAutoload.php'; 

$mail = new PHPMailer(); 

$mail->isSMTP(); 

$mail->SMTPDebug = 0; 

$mail->Debugoutput = 'html'; 

$mail->Host = "removed"; 

$mail->Port = 25; 

$mail->SMTPAuth = true; 

$mail->Username = "removed"; 

$mail->Password = "removed"; 
//Set who the message is to be sent from 
$mail->setFrom('[email protected]', 'John Doe'); 

$mail->addReplyTo('[email protected]', 'John Doe'); 
//Set who the message is to be sent to 
$mail->addAddress($email,$full); 

$mail->Subject = 'Subject'; 
$mail->Body  = $body; 
$mail->IsHTML(true); 
$mail->send(); 
+0

什麼是764在/home4/elliot/public_html/web.com/class.phpmailer.php? – lePunk

+0

$ address = trim($ address); –

+0

你在哪裏首先定義$地址? – JamesG

回答

8

我明白了。 IT是如此愚蠢的錯誤。我爲對象和電子郵件地址使用$ mail變量。

相關問題