Welcome Guest, Not a member yet? Register   Sign In
email subject in utf 8 is not work!
#1

[eluser]vee[/eluser]
this is subject in Thai language.
$subject = "หัวข้อของอีเมล์ภาษาไทย UTF-8"

if i just use
Code:
$this->email->subject($subject);
subject in email is
Quote:หัวข้อ��ทย UTF-8



i have to add encode utf-8 for multi language subject work (refer from http://www.php.net/manual/en/function.mail.php)
then i use this code
Code:
'=?UTF-8?B?'.base64_encode($subject).'?='
and send...
subject in email is
Quote:=?UTF-8?B?4Lir4Lix4Lin4LiC4LmJ4Lit4LiC4Lit4LiH4Lit4Li14LmA4Lih4Lil4LmM4Lig4Liy4Lip4Liy4LmE4LiX4LiiIFVURi04?=



but..

i check on system/libraries/Email.php page
comment/remove this line
Code:
$subject = $this->_prep_q_encoding($subject);
and send again.
it's work!

so.. i don't know what's that line for?
for make subject utf-8 won't work?
is there a way to make it work without mess with ci library?

thank you
#2

[eluser]Jazmo[/eluser]
You can't do anything without modifying the ci library or extending the email library. I have the similar problem. I don't know why there's a need for _prep_q_encoding, because '=?utf-8?B?'. base64_encode($subject). '?=' seems to work everywhere in every situation.
#3

[eluser]Jazmo[/eluser]
Put
Code:
class MY_Email extends CI_Email
{
    /**
     * Set Email Subject
     *
     * @access    public
     * @param    string
     * @return    void
     */
    function subject($subject)
    {
        $subject = '=?'. $this->charset .'?B?'. base64_encode($subject) .'?=';
        $this->_set_header('Subject', $subject);
    }
}
this to your application / libraries / MY_Email.php
#4

[eluser]Unknown[/eluser]
Just to let you all know.
All emails i sended from CI had '=?UTF-8?B?' as subject, i diged the wrong direction so it costed me "some" time to find out that the problem was that i sended an empty string to the subject (because of empty lang file).
Case solved Wink
Cheers,
Gerard
#5

[eluser]Unknown[/eluser]
@Jazmo:

How do I load this library? This doesn't work:

Code:
$this->load->library('MY_Email')
#6

[eluser]Narf[/eluser]
This issue has already been fixed in CodeIgniter's GitHub repository. You can get the fixed version from here:
https://github.com/EllisLab/CodeIgniter/.../Email.php
#7

[eluser]moonmoomin[/eluser]
Thank you




Theme © iAndrew 2016 - Forum software by © MyBB