기본 콘텐츠로 건너뛰기

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

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

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 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

MariaDB 에서 access denied for user 'root' 문제

MariaDB 에서 access denied for user 'root' 문제 heidisql 등의 원격 접속 툴을 이용해도 접속이 안 됐다. 포트, 방화벽 설정 등등 모두 확인해 봤고 로컬에서 잘 돌아가는 데도 원격 접속이 안됐다. 사실 원격 접속만 안 되면 상관 없는데, codeigniter에서도 똑같이 로그인을 못해서 자꾸 에러가 났었다. 일단, MariaDB는 10.4부터 root 권한 소유자에게 따로 비밀번호를 물어보지 않는다. 즉, 루트 계정으로 로그인했으면 그냥 콘솔에 mysql 치면 접속이 된다. 물론 다른 유저는 전처럼 비밀번호를 물어본다. 나는 이 root 계정으로 로그인을 며칠째 계속 시도해 봤는데 계속 안됐다.... 포트 문제도 아니었고 딱히 통신 문제도 아니었다. 심지어 SSH 접속 계정도 root 였다. 해답은 새로운 계정을 파서, 그 계정으로 접속을 하니까 잘 됐다. 계정 만드는 SQL 문이야 검색하면 바로 나올 거니까 따로 적진 않겠다.사실 별 내용 없는 건 아는데 새 계정을 파서 시도하란 말을 며칠 내내 구글을 뒤진 다음에야 본 것 같아서, 혹시 같은 어려움을 겪는 사람들이 있다면 빨리 해결할 수 있었으면 좋겠다. from http://skyseven73.tistory.com/5 by ccl(A) rewrite - 2020-03-11 02:54:31

[공학] 목차

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