Reply to Re: Unicode entities in email subject

Your name:

Reply:


Posted by Laangen_LU on 12/11/06 15:04

Thank you very much Umberto and Andy for your help.

The script is working now and Chinese emails arrive with nice rendrered
Chinese subjects lines.

I found the following function written by ronen to convert Unicode
entities back to a unicode string:

http://www.zend.com/codex.php?id=838&single=1

Using this before doing the base64 encoding does the trick.

Cheers,
Patrick Huss


Umberto Salsi schrieb:

> "Laangen_LU" <patrick.huss@gmail.com> wrote:
>
> > my first post to this group, so if I'm on the wrong group, my
> > apologies.
> >
> > I'm trying to send out an email in Chinese lanuage using the mail()
> > function in PHP.
> >
> > Subject and mailbody are stored as Unicode entities (eg. &#35387;)
> >
> > The mail body renders perfectly in all tested emailclients if the mail
> > is sent as html.
> >
> > Only the subject displays the entities but does not render the Chinese
> > chars.
> >
> > Any ideas on how to get the mail sent with the subject displaying
> > correctly?
> >
> > Thank you in advance for any clue available on this topic.
>
> The "Subject" field can be encoded as MIME header (see RFC 2045-2048).
> For example, given the subject $subj encoded as a UTF-8 string,
> a possible encoding might be
>
> define("ENCODING", "UTF-8");
>
> $header = "Subject: =?" . ENCODING . "?B?" . base64_encode($subj) . "?=\r\n";
>
> Note that the RFC 2047 sets a limit to the maximum lenght of the resulting
> string. Beyond that limit the string must be splitted somewere. However,
> the email clients I tested are able to accept a string of any length,
> so this is a problem you may ignore as a first step of the implementation.
>
> And note that this encoding has nothing to do with the Content-Type
> field or the body of the message.
>
> Obviously, your "Unicode entities" must be converted to regular UTF-8
> characters before the Base64 encoding be applied.
>
> Regards,
> ___
> /_|_\ Umberto Salsi
> \/_\/ www.icosaedro.it

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация