기본 콘텐츠로 건너뛰기

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

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

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', $( ...

2017년 1월 스타트업에서 구인할때 주로 원하는 개발 기술

2017년 1월 스타트업에서 구인할때 주로 원하는 개발 기술 php mysql linux android git kotlin gcm/fcm python mssql mongodb amazon aws ios objective-c swift github python c++ django python postgresql amazon aws html5/css3/javascript android java mysql python c++ c# java aws cloud-server dbms node.js postgresql redis nginx react.js hapi.js amazon aws restful-api angularJS jQuery html5/css3/javascript android firebase custom ui component restful-api asp.net c# html css javascript bootstrap angularjs node.js php mongodb redis 프론트엔드 주요 기술 javascript jquery ajax angularjs wbesocket html5/css3/javascript android ios java xcode node.js coffeescript mysql amazon ec2 amazon es3 android ios node.js php python java ios php mysql apache python android redis node.js jquery msa node.js java restful-api linux nosql golang redis nginx ...

[공학] 목차

[공학] 목차 자동차공학 컴퓨터공학 컴퓨터공학 | 개발환경 컴퓨터공학 | 웹개발 컴퓨터공학 | 모바일개발 ✓ 컴퓨터공학 | 운영체제 컴퓨터공학 | 프로그래밍 컴퓨터공학 | 네트워크 컴퓨터공학 | 데이터베이스 from http://sanctacrux.tistory.com/679 by ccl(A) rewrite - 2020-03-12 16:54:22