2010-02-04 89 views
0

我在php中寫了一封郵件聯繫表。我正在使用Pear Mail包來發送電子郵件。它在我的開發計算機上很好地工作,但不在服務器上。這裏是代碼:用PHP發送帶梨的郵件時出現問題

////////////////////////////////////////////////// 
// EMAIL OPTIONS 
////////////////////////////////////////////////// 
$to = "[email protected]";    
$subject = "Contact Form Submission";   
$smtphost = "localhost"; 
$port = "25"; 
$authenticate = false; 
$username = "smtp_username"; 
$password = "smtp_password"; 

// create and send the email 
$from = $_POST['fullname'] . " <" . $_POST['email'] . ">"; 
$body = str_replace($ph, $rv, $emailTemplate); 

$headers = array (
    'MIME-Version' => '1.0', 
    'Content-type' => 'text/html; charset=iso-8859-1', 
    'From' => $from, 
    'To' => $to, 
    'Subject' => $subject); 

$smtp = Mail::factory('smtp', 
    array ('host' => $smtphost, 
    'port' => $port, 
    'auth' => $authenticate, 
    'username' => $username, 
    'password' => $password)); 

$mail = $smtp->send($to, $headers, $body); 

$error = PEAR::isError($mail); 

if ($error){ 
    echo 'An error occurred.'; 
} 
else { 
    require('thanks.php'); 
    exit; 
} 

我不知道它爲什麼在服務器上失敗。我怎樣才能從我的$ error對象中獲得更多有用的信息?與

呼應$錯誤結果

1 

回答

0

嘗試了變化的$smtphost = "localhost"; 到你的服務器的域名網址

+0

不回答關於從$ error對象獲取更多有用信息的問題。我並不擔心我的smtp服務器主機錯誤。 – 2010-02-04 17:17:43

+0

請發佈$ error的輸出 – streetparade 2010-02-04 20:29:53

+0

如果我只是回顯$ error,我只能得到1。 – 2010-02-04 21:24:10

相關問題