2013-01-09 35 views
0

我可以從我的本地服務器發送電子郵件。但是,當我試圖從Web服務器發送電子郵件則顯示以下信息:沒有發送 消息 梅勒錯誤:語言字符串未能加載:connect_host如何使用phpmailer從網絡服務器發送電子郵件

這裏是我的代碼:

<?php 
require("class.phpmailer.php"); 

$name=$_POST['name']; 
$company=$_POST['company']; 
$email=$_POST['email']; 
$phone=$_POST['phone']; 
$subject=$_POST['subject']; 
$question=$_POST['question']; 


     $mailer = new PHPMailer(); 
     $mailer->IsSMTP(); 
     $mailer->Host = 'ssl://smtp.gmail.com'; 
     $mailer->Port = 465; //can be 587 
     $mailer->SMTPAuth = TRUE; 
     $mailer->Username = '[email protected]'; // Change this to your gmail address 
     $mailer->Password = '*********'; // Change this to your gmail password 
     $mailer->From = '[email protected]'; // Change this to your gmail address 
     $mailer->FromName = 'Client'; // This will reflect as from name in the email to be sent 
     $mailer->Body = "Name :".$name."\n\nCompany :".$company."\n\nEmail :".$email."\n\nPhone :".$phone."\n\n\n".$question.""; 
     $mailer->Subject = $subject; 
     $mailer->AddAddress('[email protected]'); // This is where you want your email to be sent 
     /*$mailer->AddAttachment('attach_file/'.$_FILES["file"]["name"]);*/ 
     if(!$mailer->Send()) 
     { 
      echo "Message was not sent<br/ >"; 
      echo "Mailer Error: " . $mailer->ErrorInfo; 
     } 
     else 
     { 
      header ('Location:index.html'); 
     } 
?> 
+0

一些供應商阻止郵件功能,以防止垃圾郵件發送來自他們的系統。你有哪些提供者? –

+0

我從本地託管提供商公司租用服務器。 eicra soft ltd – user1493448

+0

我建議你試試SwiftMailer。 –

回答

0

嘗試上傳所有的PHPmailer文件到您的網絡服務器。您可能已經忘記了語言文件夾。

您可能還需要設置你的語言:

$mail = new PHPMailer(); 
$mail->SetLanguage('en', 'phpmailer/language/'); 
+0

我已經上傳phpmailer.lang-en.php – user1493448

+0

檢查我的更新。 – SeanWM

+0

現在顯示以下錯誤消息:致命錯誤:調用成員函數SetLanguage() – user1493448

0

我認爲你必須設置的語言在你的腳本一樣

<?php 
require("class.phpmailer.php"); 
SetLanguage('en','phpmailer/language/'); 

$name=$_POST['name']; 
$company=$_POST['company']; 
$email=$_POST['email']; 
+0

現在顯示以下錯誤消息:致命錯誤:調用成員函數SetLanguage() – user1493448

+0

更新: 添加正確的行。結果將是: '$ mailer = new PHPMailer(); $ mailer-> SetLanguage('en','phpmailer/language /'); $ mailer-> IsSMTP();' – kingmo

相關問題