폼메일 $email_message 부분이 깨져서 작동합니다 ㅠㅠ

폼메일 $email_message 부분이 깨져서 작동합니다 ㅠㅠ

QA

폼메일 $email_message 부분이 깨져서 작동합니다 ㅠㅠ

본문

안녕하세요 폼메일이 깨져서 질문드립니다 ㅠ

게시판에 고마우신분이 올려주신 폼메일 사용중인데

daum이나 naver에서는 깨지지 않고 잘 작동하는데 

특정 웹메일에서 깨져서 보내지더라구요

혹시 해결법 아시는분은 도와주세요 ㅠㅠ

 

3717576197_1551330416.0613.png

<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']) ||
        !isset($_POST['telephone']) ||
        !isset($_POST['comments'])) {
        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
    $telephone = $_POST['telephone']; // not required
    $comments = $_POST['comments']; // 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);
  }
     
    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";
    $email_message .= "연락처 : ".clean_string($telephone)."\n\n";
    $email_message .= "문의사항 : ".clean_string($comments)."\n\n";
     
     
// create email headers
$headers = 'From: '.$email_from;
// 제목이 깨질경우 아래 캐릭터셋 적용

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

이 질문에 댓글 쓰기 :

답변 3

일부 웹메일에서는 html을 삭제시키는 경우가 있는걸로 알고있습니다.

즉 <meta charset="utf-8"> 이 삭제되는거죠 그래서 깨지는것일텐데... utf-8을 php밖깥쪽이 아닌 header에 넣어보시기 바랍니다.

메타태그를 삭제하고 

php 상단에 

header("content-type: application/json; charset=utf-8");

넣어봐주세요

DB언어셋이 euc-kr 이 아닌가 합니다~ 이럴경우

$wr_name = iconv("euc-kr", "utf-8", $wr_name);
$wr_subject = iconv("euc-kr", "utf-8", $wr_subject);
$wr_content = iconv("euc-kr", "utf-8", $wr_content);

으로 인코딩을 해서 넘겨야 합니다~

저도 저소스에서여쭤볼게있는데욤 ㅠㅠ

<tr>
<th scope="row">
<label for="aa14">위치</label></th>
<td>
<input name="aa14"  type="text" class="ipt" style="height:20px" size="30" maxlength="30" required >
</td>
</tr> 

 

aa14 위치 항목을 추가하려면 어떻게해야하나요?

 

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

회원로그인

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