메일 수신했을때 한글 깨지는 현상
본문
폼메일 이용해서 메일 보내는것까진 문제없었는데
네이버메일을 제외한 타 메일주소로 수신했을때
한글로된 제목 및 파일명이 깨지는 현상이 발생합니다..
해결법 알려주시면 감사하겠습니다.
// --- 헤더 --- //
$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 = "";
!-->
답변을 작성하시기 전에 로그인 해주세요.