2013-04-22 63 views
1

我正在爲我的項目使用codeignator框架。當發送郵件時,一些日文字符在電子郵件中丟失。我檢查了控制器和所有字符都存在。我檢查了配置,電子郵件charaset,發現它是utf-8 。我還添加了這個「header('Content-Type:text/html; charset = utf-8');」 。此外,從同一項目發送的郵件也沒有問題,只存在於此特定電子郵件的問題。電子郵件中缺少日文字符

公共職能的電子郵件(){

   if($this->lan == "en"){ 

       $site_name  = "xyz.com"; 
       $fromname   = "xyz.com"; 
       $subject   = 'sub 【'.$site_name.'】'; 
       $content   = " Content of email from ".$site_name."<br /><br />"; 
       }else{ 

       $site_name   = "japanesename.com"; 
       $fromname   = "japanesename.com"; 

       header('Content-Type: text/html;charset=utf-8'); 

       $subject   = 'japanesesub【'.$site_name.'】'; 
       $content   = " 

            jp content".$site_name."<br />"; 
       } 

     $to     = $email; 
       $this->load->library('email'); 
       $this->email->set_mailtype('html'); 
       $this->email->from($fromemail,$fromname); 
       $this->email->to($to); 
       $this->email->subject($subject); 
       $this->email->message($content); 
       $this->email->send(); 
       redirect('redirect_url'); 
} 
+0

更多詳細資料!文本從哪裏來?它如何被插入到電子郵件中?你如何發送電子郵件?儘可能詳細地提供您的信息! – deceze 2013-04-22 08:45:31

+0

看看:http://social.msdn.microsoft.com/Forums/en-US/sqldriverforphp/thread/46cb4626-716f-4fd7-af49-4b6fe1e5b955/ – 2013-04-22 09:20:15

回答

0

你不需要標題,而不是你需要設置字符集的配置,你開始你的其他電子郵件代碼之前:

// Set mail config variables 
$config['charset'] = 'utf-8'; 
$this->email->initialize($config);    

而且即使您希望它們已經是utf-8編碼,您也必須將任何字符串編碼爲UTF-8

$content = mb_convert_encoding($content, "UTF-8"); 
相關問題