Page 1 of 1

email subject utf-8 encoding

Posted: Mon Jan 28, 2013 2:58 pm
by jonghwa
Hi,

The default language of my cart is not English, but Korean, and the cart version is 1.5.4.1.

If the order is complete, the cart sends an email by "system/library/mail.php".

If the protocol is "mail", it encodes the subject correctly as follows:

Code: Select all

                if ($this->protocol == 'mail') {
                        ini_set('sendmail_from', $this->from);

                        if ($this->parameter) {
                                mail($to, '=?UTF-8?B?' . base64_encode($this->subject) . '?=', $message, $header, $this->parameter);
                        } else {
                                mail($to, '=?UTF-8?B?' . base64_encode($this->subject) . '?=', $message, $header);
                        }
However, it does not encode the subject if the protocol is "smtp" (not "mail").

Code: Select all

                if ($this->protocol != 'mail') {
                        $header .= 'To: ' . $to . $this->newline;
                        $header .= 'Subject: ' . $this->subject . $this->newline;
                }
I believe that most of non-English mail clients will try to decode the subject in their own language character set if not specified. Of course, it shows broken title.

I changed the line:

Code: Select all

                        $header .= 'Subject: ' . $this->subject . $this->newline;
into

Code: Select all

                        $header .= 'Subject: ' . '=?UTF-8?B?' . base64_encode($this->subject) . '?=' . $this->newline;
It works fine.

Please, consider the core code update. Thank you.

Re: email subject utf-8 encoding

Posted: Mon Mar 25, 2013 5:33 am
by iLef
Thank you veeeeeeeeeeeeeeeery much my friend!

It works great!

Good Job!

Greetings From Greece!

Lefteris._

Re: email subject utf-8 encoding

Posted: Mon Mar 25, 2013 8:05 am
by butte
More generally, customary character sets are broadly regional, such as western ISO-8859-1, unicode UTF-8, and several others. Forcing everyone to UTF-8 is probably not the best change to core. Either an installation option (also probably not best) or an admin panel setting (probably the most likely acceptable to most people) for character sets would allow people to set it as they wish. An additional wrinkle is that browsers provide a setting for Character Encoding (however worded), and that can override a website, while in your own region most users may already have their browsers preset to favor UTF-8. Hard-recoding the line to a preference, as you did to UTF-8, remains an option that anyone can use.

Re: email subject utf-8 encoding

Posted: Fri Jan 10, 2014 8:04 am
by tango@gxm.dk
Thank YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Did this small vQMod to make the change without changing the original file.

Regards
Thomas

Re: email subject utf-8 encoding

Posted: Fri Feb 28, 2014 5:08 am
by adriankoooo
Yesss! Thank you. :)

Re: email subject utf-8 encoding

Posted: Sun Jan 31, 2016 6:35 am
by p3nsy
Hello! I'm having this same problem but the other way around, I get the random UTF-8 email subjects when I'm using protocol 'mail' and I just don't find any source on how to fix it, so far your solution is the most similar but it didn't fix it when I tried :(