CakePHP Email Encoding

February 12, 2008

My email was not getting sent using the email component in CakePHP. I debugged inside the core and found out that my subject was getting changed to something like,“=?UTF-8?B?V2VsY29tZ…”.

In talking to Larry (core CakePHP team), he educated me that this allows for characters other than the English language to be sent via email (UTF-8 encoding). Even though it apparently was correct, it was still not being received at my personal email or a Yahoo account. Gmail got it, the others didn’t.

The Alternate Email Encoding (English only)

Larry showed me the alternative way to encode that works just fine for English characters. If you are having trouble with receiving these UTF-8 encoded emails, try sending with iso-8859-15 (only English characters). You can try the English encoding using this line of code:

$this->Email->charset = 'iso-8859-15';
@@@

This works for English-only applications, but if anyone can offer up a solution as to why Yahoo and Media Temple email accounts are not getting the UTF-8 emails please let me know. It is strange to me that gmail gets it just fine. Until then, I am only planning on sending English emails anyway so there is no issue until I build a multi-lingual application.


6 comments

#1. Jason Leveille on February 13, 2008

Are you specifying smtp?

$this→Email→delivery = ‘smtp’;

If so,what is the outgoing email setting for your email account? Just curious.

#2. Marc on February 13, 2008

No, I am not specifying smtp at all. Just the basics – to, from, subject and message.

#3. Donnerbeil on May 19, 2008

Hi!
Did you find any solution for multilanguage support, yet? I have the same problem. Even if I don’t use any non english characters, the mail is empty. I never had this problem with phpmailer. So there is really something to improve in cakephps email component.

#4. Marc on May 20, 2008

I haven’t found or needed a solution for multi language support.

#5. pashcan on August 04, 2008

I believe it might have something to do with the SPAM filtering Yahoo is using. I cannot get Cake’s Email component to send to my university’s email account, but gmail is also fine. Kind of annoying! Could you please let us know if you managed to bypass this issue. Thanks!

#6. T0aD on September 17, 2008

Not working here, Squirrelmail still has problems with french accents wrote in UTF-8, saved in UTF-8 and sent as UTF-8 by email. :/

Leave a comment

Comment in textile images by gravatar