기본 콘텐츠로 건너뛰기

코드이그나이터 메일 전송시 한글 깨짐 현상 해결 방법

코드이그나이터 메일 전송시 한글 깨짐 현상 해결 방법

Jason park@ 2019. 6. 13. 15:51

코드이그나이터 메일 전송시 인코딩 설정을 했음에도 불구하고 한글이 깨질 경우, 아래와같은 현상이 발생한다.

한글이 깨져 보인다.

해결 방법은 인코딩 설정과 더불어 줄바꿈 문자를 설정해주는것이다.

$this->email->set_crlf( "\r

" );

적용후 메일을 보내 테스트 해보면 아래와같이 잘 전송되는것을 볼수 있다.

깨지는 문자 없이 잘 보인다.

아래는 html 파일을 불러서 메일을 보내는 전체 소스이다.

$content = file_read($_SERVER['DOCUMENT_ROOT']."/html/mail_form.html"); $content = str_replace('::user_name::', $user_info['user_name'], $content); $to = 'mail1@mail.com, mail2@mail.com'; $title = '[BRTECH] Hello email'; $config['mailtype'] = "html"; $config['protocol'] = 'smtp'; $config['smtp_host'] = 'smtp.office365.com'; $config['smtp_user'] = 'myaccounts@mail.com'; $config['smtp_pass'] = 'password'; $config['smtp_port'] = '587'; $config['smtp_crypto'] = 'tls'; $config['charset'] = 'utf-8'; $config['newline'] = "\r

"; $config['dsn'] = true; $this->load->library('email', $config); $this->email->set_header('Content-Type', 'text/html'); $this->email->from('myaccounts@mail.com', 'from name'); $this->email->to($to); $this->email->subject($title); $this->email->set_mailtype("html"); $this->email->set_crlf( "\r

" ); $this->email->message($content); $sent = $this->email->send(); if ($sent) { echo 'OK'; } else { echo $this->email->print_debugger(); }

php codeigniter email encoding problem

PHP 코드이그나이터 한글 깨짐 현상 해결

from http://brtech.tistory.com/117 by ccl(A) rewrite - 2020-03-07 12:21:48

댓글

이 블로그의 인기 게시물

[PHP] 코드이그니터 - 파일업로드 구현

[PHP] 코드이그니터 - 파일업로드 구현 파일 업로드 이번에 PHP 프레임워크인 코드 이그니터(Codeigniter)를 사용하여 홈페이지를 만드는데 사용한 이미지 업로드용 코드 입니다. upload 라이브러리를 사용하고 app~ 와 같은 위치에 upload 폴더를 만드고 다음 코드를 사용한다음 ajax 로 호출하여 파일을 업로드 합니다. function index() { // Upload 설정 $config['upload_path'] = './upload/'; $config[\'allowed_types\'] = 'gif|jpg|png'; $config['max_size'] = 100; // 100k $config['max_width'] = 1024; $config['max_height'] = 768; $this->load->library('upload', $config); $data = array(); if (! $this->upload->do_upload("service_image")) { $error = array('error' => $this->upload->display_errors()); } else { //$data = array('upload_data' => $this->upload->data()); $this->output->set_output("./upload/".$this->upload->data('file_name')); } } jquery 를 이용한 파일 업로드 호출 코드 function upload() { var datas, xhr; datas = new FormData(); datas.append( 'service_image', $( ...

PHP framework 종류

PHP framework 종류 분류 전체보기 (1461) API (0) Android (19) Common (11) Component (0) adb (2) DDMS (1) GCM (4) HTTP (0) sqlite (1) View (0) build (0) Bigdata (4) Common (1) Hadoop (2) Spark (0) SQL on Hadoop (1) Cloud (12) Common (8) Multitenancy (2) OpenStack (0) UCloud (2) Computer Science (24) Common (4) Asynchronous IO (1) Cache (6) Distributed (0) Message Queue (1) Parallel Computing (5) Software Engineering (7) DB (172) Common (32) HSQLDB (1) In-memory DB (0) MariaDB (2) MongoDB (30) MySQL (69) NoSQL (8) Oracle (17) ORM (6) Redis (1) SQL Server (6) Design Pattern (7) Common (7) Programming paradigms (0) Reactor (0) Development (459) Common (37) AngularJS (3) Bootstrap (3) C (22) C++ (0) CSS (32) HTML (31) HTML5 (2) Java (118) JavaEssential (25) JSP & Servlet (33) JavaScript (69) jQuery (26) jQuery Mobile (4) Linux Programming (3) python (3) PHP (21) Reactive Streams (0) ShellScript (5) UML (6) Windows Programming (2) XML (14) Framework & Platform (161) Common (8) EFL (1) mybati...

이클립스 코드이그나이터 연동 ( eclipse codeigniter )

이클립스 코드이그나이터 연동 ( eclipse codeigniter ) https://ellislab.com/codeigniter/user-guide/installation/downloads.html 위의 사이트에서 코드이그나이터를 다운 받는다. 다운받은 압축 파일을 풀어 준다. 이클립스에서 php 프로젝트를 생성한 공간에 코드이그나이터 압축파일을 복사 붙여넣기 해준다. 위와 같은 화면이 나오면 정상적으로 연동이 된 것 입니다. from http://nahosung.tistory.com/22 by ccl(A) rewrite - 2020-03-06 16:20:55