폼메일 문의입니다

폼메일 문의입니다

QA

폼메일 문의입니다

본문

https://sir.kr/g5_skin/10486

덕서리님이 올려주신 글 읽고 폼메일폼을 만들고있습니다.

 

제가 필요한건 이름, 이메일 뿐이라서 수정해봤는데요,

 

 

 



<form name="contactform" method="post" action="send.php">


<div class="row">
    <div class="col-12 main01-bottom-right-link-newsletter-name">
        <!--<input type="text" name="mb_name" id="inputName" placeholder="이름" required="">-->
        <input type="text" name="first_name" id="inputName" placeholder="이름" required="">
    </div>
</div>
<div class="row">
    <div class="col-12 main01-bottom-right-link-newsletter-email">
        <!--<input type="text" name="mb_email" id="inputEmail" placeholder="이메일주소" required="">-->
        <input type="text" name="email" id="inputEmail" placeholder="이메일주소" required="">
    </div>
</div>

 

<div class="row">
    <div class="col-12 p-0" >
        <button type="submit" class="btn_submit">신청</button>
    </div>
</div>

 
 
</form>

 

send.php



<meta charset="utf-8">
<?php
if(isset($_POST['email'])) {
     
    
   $email_to = "*** 개인정보보호를 위한 이메일주소 노출방지 ***";
   $email_subject = "[폼메일] 문의사항입니다.";
   $email_subject = '=?UTF-8?B?'.base64_encode($email_subject).'?=';

     
     
    function died($error) {
        // your error code can go here
        echo "<script> alert('메일발송을 실패하였습니다.');";
      echo "history.go(-1);";
      echo "</script>";
        die();
    }
     
    // validation expected data exists
    if(!isset($_POST['first_name']) ||
        !isset($_POST['email'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
    }
     
    $first_name = $_POST['first_name']; // required
    $email_from = $_POST['email']; // required
     
    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    
  if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "";
     
    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }
     
    $email_message .= "이름 : ".clean_string($first_name)."\n\n";
    $email_message .= "이메일 : ".clean_string($email_from)."\n\n";
     
     
// create email headers
$headers = 'From: '.$email_from;
// 제목이 깨질경우 아래 캐릭터셋 적용

@mail($email_to, $email_subject);
?>
 
<!-- include your own success html here -->
 
<script>
alert ("메일이 발송되었습니다.\n빠른 시일안에 답변드리겠습니다.");
location.href='../';
</script>
 
<?php
}
?>

이렇게 했는데 계속 메일발송에 실패했다고 뜨네요,,

 

계속 에러로 넘어가는거같은데 도통 이유를 모르겠습니다

 

도와주세요ㅜ

 

이 질문에 댓글 쓰기 :

답변 2

에러라는게 어떤건지 모르겠지만 sendmail 발송 모듈의 문제가 있는건 아닌지

혹은 소스의 오류가 있는게 아닌지 오류라는게 정확하지 않아서 답변드리기가 어렵습니다.

 

보다보니 메일 발송시 발송자정보만 있고 보내는사람이랑 내용이 없는듯 한데 그 부분을 체크해 보셔야 할듯 합니다.

 

메일 발송 함수 사용 참조

@mail($to_email,$subject,$contents,$header);

@mail($email_to, $email_subject, $email_message, $headers);

 

이렇게 한번 변경해 보세요.

답변을 작성하시기 전에 로그인 해주세요.
전체 123,123 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT