2009-10-27 6 views
0

AJAX와 함께 PHP 메일 양식을 사용하고 있으며 메일을 보내지 않습니다. 내가 여기서 무엇을 놓치고 있니?내 AJAX 양식이 전자 메일을 보내지 않는 이유는 무엇입니까?

send.php

<?php 
    error_reporting(E_NOTICE); 

    function valid_email($str) 
    { 
     return (! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; 
    } 

    if($_POST['first_name']!='' && $_POST['last_name']!='' && $_POST['e_mail']!='' && valid_email($_POST['e_mail'])==TRUE && strlen($_POST['message'])>30) 
    { 
     $to = '[email protected]'; 
     $headers = 'From: '.$_POST['e_mail'].''. "\r\n" . 
       'Reply-To: '.$_POST['e_mail'].'' . "\r\n" . 
       'X-Mailer: PHP/' . phpversion(); 
     $subject = "Hello! I'm testing my new ajax email that I got from roscripts.com"; 
     $message = htmlspecialchars($_POST['message']); 

     if(mail($to, $subject, $message, $headers)) 
     {//we show the good guy only in one case and the bad one for the rest. 
      echo 'Thank you '.$_POST['first_name'].'. Your message was sent'; 
     } 
     else { 
      echo "Message not sent. Please make sure you're not 
       running this on localhost and also that you 
       are allowed to run mail() function from your webserver"; 
     } 
    } 
    else { 
     echo 'Please make sure you filled all the required fields, 
     that you entered a valid email and also that your message 
     contains more then 30 characters.'; 
    } 
?> 
+3

에코됩니다. – Greg

+0

메시지가 에코됩니다. – HollerTrain

답변

0

은 PHP에서 이메일 설정인가? 먼저 확인하십시오, 그렇지 않으면 여기서 볼 수있는 문제가없는 것 같습니다. 이 if/else 블록에서 어떤 종류의 출력을 얻어야합니다.

PHP 오류 로그를 검토하여 mail() fn이 작동하는지 확인합니다. 그것이 원인 일 수 있습니다.

+0

메시지 오류입니다. 메시지가 30보다 작 으면 오류를 보여줍니다! – HollerTrain

관련 문제