2013-12-12 180 views
0

我有一個簡單的網站,用戶填寫並點擊提交後,其發出的電子郵件中的聯繫人形式,但是這似乎並沒有工作,PHP代碼不發送電子郵件

不幸的是我不無法訪問郵件服務器本身,因爲它是託管,

我該如何調試?

<?php 
require_once "Mail.php"; 

$from = "B A <[email protected]>"; 
$to = "B B <[email protected]>"; 

    if($subject!=""){ 
    $subject =$_REQUEST['subject']; 
    }else{ 
    $subject = 'Lighter Contact Form'; 
    } 

    $name=$_REQUEST['name']; 
    $email=$_REQUEST['email']; 
    $msg=$_REQUEST['msg']; 

    $port = "25"; 

    $body = "Name: $name \n\nEmail: $email \n\nMessage: $msg"; 
    $headers = 'From: '.$name.' <'.$email.'>' . "\r\n" . 'Reply-To: ' . $email; 

$host = "imap.ox.registrar-servers.com"; 
$username = "[email protected]"; 
$password = "password"; 


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

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

你檢查什麼記錄? – Zarathuztra

回答

1

你可以檢查錯誤響應(假設你使用的是梨Mail類:

if(Pear::isError($mail)) 
{ 
    die($mail->getMessage()); 
}