2014-11-23 53 views
1

我有以下代码在我的localhost apache上工作。PHPmailer服务器错误

date_default_timezone_set('Etc/UTC'); 

require ('bin\PHPMailerAutoload.php'); 

$uname = "[email protected]"; 

$mail = new PHPMailer(); 
$mail->isSMTP(); 
$mail->SMTPDebug = 2; 
$mail->Host = 'smtp.rybnikzahradne.sk'; 
$mail->SMTPSecure = 'tls'; 
$mail->Port = 25; 

$mail->SMTPAuth = true; 
$mail->Username = $uname; 
$mail->Password = "********"; 

$mail->From = $uname; 
$mail->AddAddress($uname); 

$mail->Subject = $_POST["from"]; 

$mail->Body = $_POST["message"]; 

$mail->AltBody = 'sprava'; 

if (!$mail->send()) { 
    echo "Mailer Error: " . $mail->ErrorInfo; 
} else { 
    echo "Message sent"; 
} 

但是,当我把它上传我的服务器上它给我这个错误:

Fatal error: require(): Failed opening required 'bin\PHPMailerAutoload.php' (include_path='.:/usr/php55/lib/php') in /nfsmnt/hosting2_1/3/b/3b4145df-8ba9-4552-835f-4e0224ac066d/rybnikzahradne.sk/web/objednavky3.php on line 5 
+0

你上传了'bin \ PHPMailerAutoload.php'并且文件名就是这样吗? – TheConstructor 2014-11-23 14:40:18

+0

@TheConstructor是的,我检查过两次。 – Quest 2014-11-23 14:46:07

+0

您是否尝试更改require-statement来使用'bin/PHPMailerAutoload.php'(正斜杠)? – TheConstructor 2014-11-23 14:47:45

回答

1

虽然PHP接受\/在Windows上,在* nix系统你可能不得不使用/为路径 - 分离器,所以改变你的线

require ('bin/PHPMailerAutoload.php'); 

它应该在两个系统上工作。