폼메일 한글 깨짐

폼메일 한글 깨짐

QA

폼메일 한글 깨짐

답변 2

본문

폼메일을 비즈메카로 사용하고있습니다.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; 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['form01']) ||
                !isset($_POST['form02']) ||
                !isset($_POST['form03']) ||
        !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
        $form01 = $_POST['form01']; // required
        $form02 = $_POST['form02']; // required
        $form03 = $_POST['form03']; // 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($form01)."\n\n";
        $email_message .= "회사명 : ".clean_string($form02)."\n\n";
    $email_message .= "담당자 : ".clean_string($first_name)."\n\n";
        $email_message .= "연락처 : ".clean_string($telephone)."\n\n";
    $email_message .= "이메일 : ".clean_string($email_from)."\n\n";
        $email_message .= "제목 : ".clean_string($form03)."\n\n";
    $email_message .= "문의사항 : ".clean_string($comments)."\n\n";

$comment1 = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
// 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
}
?>
 

코드는 이렇게 되어있고 메일을 보내게되면

 

제목: [폼메일] 문의사항입니다.

 

 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

 

쒖븞 諛 쒗쑕 遺꾩빞 : 쒕컻

 

 

뚯궗紐 : 源⑥ 吏 쭚怨

 

 

대떦 : 쒕 濡 媛 씪

 

 

곕씫泥 : *** 개인정보보호를 위한 휴대폰번호 노출방지 ***

 

 

대찓 : *** 개인정보보호를 위한 이메일주소 노출방지 ***

 

 

쒕ぉ : 洹몃쭔 섏옄

 

 

臾몄쓽 ы빆 : 吏꾩쭨 吏 껸

 

제목은 깨지지않는데

 

내용이 깨져서 나옵니다.. 고수님들 답변 부탁드립니다ㅠ

이 질문에 댓글 쓰기 :

답변 2

iconv를 사용하셔야 ...

 

   $body=$content; // 메일내용
   $body = iconv('utf-8', 'euc-kr', $body);  //본문 내용 UTF-8화

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 18
© SIRSOFT
현재 페이지 제일 처음으로