본문 바로가기

WEB_TECH/PHP

한글깨짐방지 폼메일 보내기

   $charset='UTF-8'; // 문자셋 : UTF-8
   $subject=$subject; // 제목
   $toName='홍길동'; // 받는이 이름
   $toEmail= $to; // 받는이 이메일주소
   $fromName=$cok_name; // 보내는이 이름
   $fromEmail=$cok_mail; // 보내는이 이메일주소
   $body=$content; // 메일내용
   $body = iconv('utf-8', 'euc-kr', $body);  //본문 내용 UTF-8화
   $encoded_subject="=?".$charset."?B?".base64_encode($subject)."?=\n"; // 인코딩된 제목
   $to= "\"=?".$charset."?B?".base64_encode($toName)."?=\" <".$toEmail.">" ; // 인코딩된 받는이
   $from= "\"=?".$charset."?B?".base64_encode($fromName)."?=\" <".$fromEmail.">" ; // 인코딩된 보내는이

   $headers="MIME-Version: 1.0\n".
   "Content-Type: text/html; charset=".$charset."; format=flowed\n".
   "To: ". $to ."\n".
   "From: ".$from."\n".
   "Return-Path: ".$from."\n".
   "Content-Transfer-Encoding: 8bit\n"; // 헤더 설정

   mail( $to , $encoded_subject , $body , $headers ); // 메일 보내기 



출처 : Tong - 웹프로그램창고님의 PHP통

'WEB_TECH > PHP' 카테고리의 다른 글

APMSETUP을 설치해 봅시다.  (0) 2012.10.24
PHP란 무엇인가?  (0) 2012.10.22