2014-07-13 4 views
2

저는 회사의 웹 사이트에서 일하고 고객이 HTML 양식을 작성하고 PHP를 통해 본인과 고객 모두에게 전자 메일을 보내도록합니다. 여기에 내 코드, 바로 지금 내 php를 얻을 양식을 작성한 후 제출을 클릭하면,하지만 둘 다 이메일을 보냅니다. 고마워요!PHP Sendmail이 작동하지 않음

<form action="quotes.php" method="post"> 
      Name: <input type="text" name="name" required="yes"><br> 
      Email Address: <input type="email" name="email" required="yes"><br> 
      Phone: <input type="text" name="phone" required="yes"><br> 
      Home or Business?: <input type="text" name="horb" required="yes"><br> 
      Number of int. Cameras Desired: <input type="number" name="extcam"><br> 
      Number of ext. Cameras Desired: <input type="number" name="intcam"><br> 
      Number of ext. Doors: <input type="number" name="exdrs"><br> 
      Do/Don't want Automated Door Locks?: <input type="text" name="locks"><br> 
      Number of 1st Floor Windows: <input type="number" name="winds"><br> 
      Number of Windows on Other Floors: <input type="number" name="otherwinds">  <br> 
      Do/Don't want Energy Control?: <input type="text" name="energy"><br> 
      Number of Switches to be Controlled:<input type="number" name="switches"><br> 
      Number of Outlets to be Controlled:<input type="number" name="outlets"><br> 
      Do/Don't want Automated Thermostat?: <input type="text" name="temp"><br> 
      <textarea type="text" rows="4" cols="50" name="comments">Any additional devices/comments...</textarea><br> 
      <input type="submit" value="Submit" name="submit"><br> 
      <small>*Please note a walk-through of the property may be neccessary before a final price can be determined.</small> 
     </form> 

<?php 
if(isset($_POST['submit'])){ 
    $to = "[email protected]"; 
    $from = $_POST['email']; 
    $name = $_POST['name']; 
    $subject = "Quote form submission!"; 
    $subject2 = "Confirmation of your Quote Request"; 
    $message = $name . " requested a quote for their " . $_POST['horb'] . ":" . "\n\n" . "The customer requested " . $_POST['extcam'] . " exterior cameras and " . $_POST['intcam'] . " interior cameras. They have " . $_POST['extdrs'] . " exterior doors they " . $_POST['locks'] . " want automated locks for. They have " . $_POST['winds'] . " windows on the first floor and " . $_POST['otherwinds'] . " other windows. They " . $_POST['energy'] . " want energy control and they have " . $_POST['switches'] . " switches and " . $_POST['outlets'] . " outlets to be replaced. They " . $_POST['temp'] . " want an automated thermostat. The customer commented the following:" . "\n\n" . $_POST['comments'] . ". You may contact them at either " . $_POST['email'] . " or " . $_POST['phone'] . "at your earliest convenience."; 
    $message2 = "Thank you for your quote request " . $_POST['name'] . "! This email is to confirm your quote was successfully received by NorCal Home Automation. A representative from NorCal will contact you shortly at either " . $_POST['email'] . " or " . $_POST['phone'] . ". If this contact information was entered incorrectly please email [email protected] to update your contact information. Thank you for your interest in NorCal Home Automation we look forward to having you as a satisfied customer!"; 

    $headers = "From:" . $from; 
    $headers2 = "From:" . $to; 
    mail($to,$subject,$message,$headers); 
    mail($from,$subject2,$message2,$headers2); 
    echo "Thank you " . $name . " your quote was submitted, please check your email for confirmation."; 
    } 
?> 
+0

당신이 당신의 서버가 센드 메일 설정을 가지고 확인해 봤어? 그런 다음 전자 메일을 보내는 간단한 테스트 사례를 수행 했습니까? 그런 다음 스팸 폴더에서 이메일이 손실되지 않았는지 또는 이전 스팸성 활동에 대해 IP가 금지되지 않았는지 확인 했습니까? 여기에 잘못 될 수있는 많은 것들이 있습니다. 디버깅하고 서버의 오류 로깅을 점검해야합니다. –

+0

또는 Sendgrid와 같은 타사 서비스를 확인하고 싶을 수 있습니다. – okoboko

+0

서버에 SMTP 설정이 있다는 것을 알고 있지만 sendmail을 허용하는지 잘 모르겠습니다. 오류 로그가 있는지 확인합니다. 지금은 무료 웹 호스팅 중입니다. 왜냐하면 모든 것이 제대로 작동했는지 확인하고 싶었 기 때문에 내가 시작할 준비가되었을 때 유급으로 업그레이드해야 할 이유가 무엇인지 확인하기 위해서였습니다. 고맙습니다! 편집 : 방금 확인한 후 오류 로그를 한 번만 사용할 수 있습니다. 유료로 전환 했으므로이 문제를 마지막으로 해결하면이 문제를 해결할 것입니다. –

답변

0

당신은 확인하고 PHP 인스턴스가 메일() 명령의 사용을 허용하도록 구성되어 있는지 확인해야합니다 (두 코드는 하나의 파일 이름 quotes.php에있다).

또한, 대신에 두 개의 별도의 명령을 사용하는 "숨은 참조 :"포함이 같은 헤더 :

$headers.= "Bcc: $from\n"; 
+0

헤더 제안에 감사드립니다. 그들은 나를 무료 호스팅에서 php.ini를 편집하게하지 않을 것이다. 그러나 내가 유료로 바꿀 수있을 것이라는 것을 알고있다. –