<?php $this->load->model('epaper_model'); $this->load->helper('form_helper'); $this->load->library('email'); $mail_html = $this->load->view('theme_ocbn/forget_pass_email.php', array('data' => $data), TRUE); $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.gmail.com'; $config['smtp_port'] = '465'; $config['smtp_user'] = 'your@gmail.com'; $config['smtp_pass'] = 'yourpass'; $config['mailtype'] = 'html'; $config['newline'] = "\r\n"; $config['crlf'] = "\r\n"; $config['charset'] = 'gbk'; $this->email->initialize($config); $this->email->from('your@gmail.com', iconv('utf-8', 'gbk', 'sendername')); $this->email->to($row->email); $this->email->subject(iconv('utf-8', 'gbk', $subject)); $this->email->message(iconv('utf-8', 'gbk', $mail_html)); $this->email->send(); ?>
在使用CI寄信寄到Gmail時由於Gmail信件的主旨使用utf-8的話會產生亂碼 所以之前是把編碼整個設為big5,但是卻碰到信件內文有些中文字使用big5顯示會產生亂碼 為了解決這個問題、查了許多地方、歸類出了使用gbk編碼可以支援大部分的中文字 不會產生亂碼.....果然一試寄信、本來會出現亂碼的字都正常顯現了 如果接下來遇到真的非utf-8不可的地方、好像就得改寫CI的function或使用php的perl mail了 或使用php的per mail了吧~~
全站熱搜