2017-06-07 18 views
0

下面是我的代碼,它在XAMPP服務器上正常工作。當我加載相同的Godaddy服務器,它給出了一個錯誤類'PHPMailer'找不到在Godaddy服務器上的PHPMailer

我已經加載了所有PHPmailer文件在godaddy服務器上。

<?php 
$email_from = "[email protected]"; 
$from = "Name"; 

include_once('PHPMailer/PHPMailerAutoload.php'); 
$mail = new PHPMailer(true); 

//Send mail using gmail 

$mail->IsSMTP(); // telling the class to use SMTP 
$mail->SMTPAuth = true; // enable SMTP authentication 
$mail->SMTPSecure = 'ssl'; // sets the prefix to the servier 
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server 
$mail->Port = 465; // set the SMTP port for the GMAIL server 
$mail->Username = "[email protected]"; // GMAIL username 
$mail->Password = "password"; // GMAIL password 
$mail->IsHTML(true); 

//Typical mail data 
$mail->AddAddress($email, $name); 
$mail->SetFrom($email_from, $from); 
?> 
+0

任何特定的原因,你不是基於PHPMailer提供的gmail示例代碼?你的代碼有一些基本的問題,通過使用它可以避免。此外,在這裏搜索GoDaddy SMTP問題 - 除了您的路徑問題,GoDaddy以阻止出站SMTP而聞名,因爲PHPMailer文檔會詳細告訴您。 – Synchro

回答

1

你的錯誤消息,從該行未來沒有找到/導入的PHPMailer類文件:

include_once('PHPMailer/PHPMailerAutoload.php'); 

這肯定聽起來像一個pathing issue

你的目錄路徑全部正確嗎?也就是說,這個PHP代碼 - 它是從一個PHPMailer目錄的目錄運行在同一位置嗎?如果您手動將這些文件放在您的服務器上,您的PHPMailerAutoload.php是否可以找到PHPMailer類本身?

+0

事實上 - 如果沒有你加載的文件,你的代碼就無法運行,那麼就不要使用include;使用'require'來代替。 – Synchro