2010-01-10 94 views
0

剛剛加入了幾分鐘前。聯繫我們頁面無法正常工作

我想看看是否有人能告訴我爲什麼我的聯繫人頁面沒有給我發電子郵件。

我的聯繫人頁面here

我沒有得到任何錯誤。如果你輸入你的信息,它似乎發送它。它甚至會向您發送您的電子郵件已發送的消息。但我沒有收到任何電子郵件。

上面的文檔類型我有

的formprocess.php編碼這樣的[我取出我的電子郵件,以避免垃圾郵件]:

<?php 
include('includes/corefuncs.php'); 
if (function_exists('nukeMagicQuotes')) { 
    nukeMagicQuotes(); 
    } 

// process the email 
if (array_key_exists('send', $_POST)) { 
    $to = '[email protected]'; // use your own email address 
    $subject = 'Email from your contact form'; 

    // list expected fields 
    $expected = array('name', 'email', 'comments'); 
    // set required fields 
    $required = array('name', 'email', 'comments'); 
    // create empty array for any missing fields 
    $missing = array(); 

    // assume that there is nothing suspect 
    $suspect = false; 
    // create a pattern to locate suspect phrases 
    $pattern = '/Content-Type:|Bcc:|Cc:/i'; 

    // function to check for suspect phrases 
    function isSuspect($val, $pattern, &$suspect) { 
    // if the variable is an array, loop through each element 
    // and pass it recursively back to the same function 
    if (is_array($val)) { 
     foreach ($val as $item) { 
     isSuspect($item, $pattern, $suspect); 
     } 
     } 
    else { 
     // if one of the suspect phrases is found, set Boolean to true 
     if (preg_match($pattern, $val)) { 
     $suspect = true; 
     } 
     } 
    } 

    // check the $_POST array and any sub-arrays for suspect content 
    isSuspect($_POST, $pattern, $suspect); 

    if ($suspect) { 
    $mailSent = false; 
    unset($missing); 
    } 
    else { 
    // process the $_POST variables 
    foreach ($_POST as $key => $value) { 
     // assign to temporary variable and strip whitespace if not an array 
     $temp = is_array($value) ? $value : trim($value); 
     // if empty and required, add to $missing array 
     if (empty($temp) && in_array($key, $required)) { 
     array_push($missing, $key); 
     } 
     // otherwise, assign to a variable of the same name as $key 
     elseif (in_array($key, $expected)) { 
     ${$key} = $temp; 
     } 
     } 
    } 

    // validate the email address 
    if (!empty($email)) { 
    // regex to ensure no illegal characters in email address 
    $checkEmail = '/^[^@][email protected][^\s\r\n\'";,@%]+$/'; 
    // reject the email address if it doesn't match 
    if (!preg_match($checkEmail, $email)) { 
     array_push($missing, 'email'); 
     } 
    } 

    // go ahead only if not suspect and all required fields OK 
    if (!$suspect && empty($missing)) { 
    // build the message 
    $message = "Name: $name\n\n"; 
    $message .= "Email: $email\n\n"; 
    $message .= "Comments: $comments"; 

    // limit line length to 70 characters 
    $message = wordwrap($message, 70); 

    // create additional headers 
    /*$additionalHeaders = 'From: Frank Juval Studio Site'; 
    if (!empty($email)) { 
     $additionalHeaders .= "\r\nReply-To: $email"; 
    }*/ 

    // send it 
    $mailSent = mail($to, $subject, $message, $additionalHeaders); 
    if ($mailSent) { 
     // $missing is no longer needed if the email is sent, so unset it 
     unset($missing); 
     } 
    } 
    } 
?> 

我不是PHP程序員。我從一個免費提供教程的網站抓取了這段代碼。我的專長是HTML/CSS。最終我會進入PHP。

感謝您的幫助提前。

弗蘭克

+1

沒有先看代碼,你是否證實'mail()可以在你的服務器上工作?您可以通過製作一個PHP文件並填寫'mail()'參數,然後訪問該腳本來調用電子郵件來檢查。 – Sampson

+0

是的,我的服務器支持電子郵件。我曾經有一個CMS,但把它放下,以重新設計我的網站。 – FrankDraws

回答

2

嘗試用一些簡單得多:

mail('[email protected]', 'Subject', 'Message'); 

如果它被髮送,那麼腳本可能是問題。如果不是,那麼您的主機可能不支持發送電子郵件。

+0

感謝metrobalderas的回覆。雖然它似乎沒有工作。 是的,腳本是問題。我已經做了一些工作。唯一不正確的是發送實際的消息。它發送所有其他信息(即名稱,主題,電子郵件),但不發送郵件正文。 任何想法如何解決這個問題?我將重新發布更新後的PHP代碼。 – FrankDraws

-1
<? 
$destination="mailto:[email protected]"; 
$name=$_POST['Name']; 
$Phone=$_POST['Phone']; 
$State=$_POST['State']; 
$email=$_POST['Email']; 
$mes=$_POST['Message']; 
$subject="Message from $name" ; 
$mes="Name : $name\n Phone: $Phone\n 
Email: $email\n\n Message: $mes\n"; 
mail($destination,$subject,$mes); 
?>