테스트 사이트 - 개발 중인 베타 버전입니다

폼메일 아웃룩 한글 깨지는 현상 채택완료

간한이 7년 전 조회 3,560

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

 

    $email_to = "contact@coopskorea.com";     $email_subject = "[폼메일] 문의사항입니다.";     $email_subject = '=?UTF-8?B?'.base64_encode($email_subject).'?=';

    function died($error) {         // your error code can go here         echo "";         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. ';   }

  if(strlen($comments) < 2) {     $error_message .= 'The Comments you entered do not appear to be valid. ';   }   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";

// create email headers $headers = 'From: '.$email_from; // 제목이 깨질경우 아래 캐릭터셋 적용

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

 

코드는 이렇습니다.

 

이렇게해서 메일 발송시 

 

 

이런식으로 깨져서 메일이 수신됩니다.

현재 비즈메카 쪽의 charset은 utf-8 이라고 하는데 왜깨지는건가요..ㅠ

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

채택된 답변
+20 포인트
세이세키

보통 폼메일이 깨지는경우는

1.폼메일형식이 저장되있는파일이

   저장방식이 유니코드가 다르게 저장이되어있거나(meta 백날써놔도 저장형식이 다른거면소용없음)

2. 메일에 보내지는형식에 유니코드 지정meta가 들어가있지않아 발생하는문제인데요

 

질문자님의 경우 2번이 유력해보입니다.

 

// create email headers $headers = 'From: '.$email_from; // 제목이 깨질경우 아래 캐릭터셋 적용

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

 

이부분에 아래 변수를 추가해서(변수명은 바꿔도됩니다.)

$comment1 = "";

 

아래처럼 만들어줍니다.

$comment1 = "";

// create email headers $headers = 'From: '.$email_from; // 제목이 깨질경우 아래 캐릭터셋 적용

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

 

제가 부족한실력이라 이게안되면 응용해서 해보세요.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

간한이
7년 전
답변감사합니다.
해결이 안되네요..ㅠ

댓글을 작성하려면 로그인이 필요합니다.

7년 전

email 이 utf-8 로 설정이 안되어 있네요?

예전에는 이렇게 설정했던거 같습니다.

$mail->CharSet = "UTF-8";

 

코드상에 @mail 을 utf8 로 설정해야 할거 같네요

로그인 후 평가할 수 있습니다

답변에 대한 댓글 2개

간한이
7년 전
답변 감사합니다

코드를 어디에 어떻게 넣어야할까요?ㅠ
간한이
7년 전
답변 감사합니다

코드를 어디에 어떻게 넣어야할까요?ㅠ

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인