Japanese (multi-byte) characters & email library |
[eluser]Aaron L.[/eluser]
Hello, In my controller (encoded in UTF-8) I am attempting to send an email which contains Japanese (multibyte) characters. The body of the email comes out fine, but the subject line are just garbled characters. Any ideas/tips/hints/thoughts as to what might be going on here?
[eluser]座頭市[/eluser]
This has been a headache of mine for a long time.... The standard for Japanese emails is iso-2022-jp, not utf-8 - it would be best to change your email encoding and run the subject and body text through iconv(). This will solve most, but not all, mojibake problems. For example: Code: $this->load->library('email');
[eluser]Aaron L.[/eluser]
Thanks for your reply! I will try your suggestions and let you know what happens. Thanks!
[eluser]Aaron L.[/eluser]
Hello again, I tried using your code and unfortunately the subject line still comes out as jibberish. My partner and I tried it in a couple of different mail clients and still no luck. Any other thoughts/ideas? Aaron
[eluser]座頭市[/eluser]
Yeah... like I said, it might work... ;-) Okay... check the Content-Tranfer-Encoding of your received emails... are they 7bit or 8bit? It should be 7bit. CI seems to set the encoding by default to 8-bit (understandable as UTF-8 is the default), which might be causing the mojibake, so you'll have to hack the email core to set the encoding to 7bit. It might be possible to use Code: $config['_encoding'] = '7bit';
[eluser]Unknown[/eluser]
Hello This is code for send mail in Japanese language. $ Code: this->load->library('email');
[eluser]Unknown[/eluser]
[quote author="座頭市" date="1186673766"] $this->email->subject(iconv('utf-8', 'iso-2022-jp', $subject)); $this->email->message(iconv('utf-8', 'iso-2022-jp', $message)); [/code] [/quote] I think the problem is that iconv is including 'Subject:', so it's included for a second time when sending the email. I used str_replace to remove inconv's 'Subject:' and it worked fine. |
Welcome Guest, Not a member yet? Register Sign In |