메일 수신했을때 한글 깨지는 현상

메일 수신했을때 한글 깨지는 현상

QA

메일 수신했을때 한글 깨지는 현상

본문

폼메일 이용해서 메일 보내는것까진 문제없었는데

네이버메일을 제외한 타 메일주소로 수신했을때

한글로된 제목 및 파일명이 깨지는 현상이 발생합니다..

해결법 알려주시면 감사하겠습니다.

 

 



// --- 헤더 --- //
$headers = "Return-Path: ".str_replace("\\", "", $femail)."\r\n";
$headers .= "From: ".str_replace("\\", "", $femail)."\r\n";
if($remail) {
    $headers .= "Cc: ".str_replace("\\", "", $remail)."\r\n";
}
if($hemail) {
    $headers .= "Bcc: ".str_replace("\\", "", $hemail)."\r\n";
}
if($attach_url && $attach_name) { // --- 첨부파일 --- //
    $filename=$attach_name;
    $fp = fopen($attach_url,"r");
    $file = fread($fp,$attach_size);
    fclose($fp);
    if ($attach_type == ""){
        $attach_type = "application/octet-stream";
    }
    // --- 헤더 --- //
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: Multipart/mixed;charset=ISO-2022-KR, Content-Transfer-Encoding: 7bit; boundary=\"$boundary\"";
    // --- 본문 --- // 
    $mailbody = "This is a multi-part message in MIME format.\r\n\r\n";
    $mailbody .= "--$boundary\r\n";
    $mailbody .= "Content-Type: text/html; charset=utf-8\r\n";
    $mailbody .= "Content-Transfer-Encoding: base64\r\n\r\n";
    $mailbody .= chunk_split(base64_encode(str_replace("\\", "",$subject. "\r\n" .$s_date. "\r\n" .$add. "\r\n" .$u_name. "\r\n" .$u_tel. "\r\n"  .$b_date. "\r\n" .$message))) . "\r\n";
    // --- 첨부 --- // 
    $mailbody .= "--$boundary\r\n"; 
    $mailbody .= "Content-Type: ".$attach_type."; name=\"".$filename."\"\r\n";
    $mailbody .= "Content-Transfer-Encoding: base64\r\n";
    $mailbody .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
    $mailbody .= base64_encode($file)."\r\n\r\n";
    $mailbody .= "--$boundary--";
}
else {
    // --- 헤더 --- // 
    $headers .= "MIME-Version: 1.0\r\n"; 
    $headers .= "Content-Type: Multipart/alternative; boundary = \"$boundary\"";
    // --- 본문 --- //
    $mailbody = "--$boundary\r\n"; 
    $mailbody .= "Content-Type: text/html; charset=utf-8\r\n";
    $mailbody .= "Content-Transfer-Encoding: base64\r\n\r\n";
    $mailbody .= chunk_split(base64_encode(str_replace("\\", "",$subject. "\r\n" .$s_date. "\r\n" .$add. "\r\n" .$u_name. "\r\n" .$u_tel. "\r\n"  .$b_date. "\r\n" .$message))) . "\r\n";
    $mailbody .= "--$boundary--\r\n\r\n"; 
}
$ret = mail($temail, $subject, $mailbody, $headers);
if(!$tit || !$u_name|| !$u_tel){
    alert('잘못된 접근입니다.');
    exit;
}
$file = "";

 

 

이 질문에 댓글 쓰기 :

답변 1

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

회원로그인

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