You are here: Re: Non-ascii email subject and header encoding « PHP Programming Language « IT news, forums, messages
Re: Non-ascii email subject and header encoding

Posted by Erwin Moller on 03/27/07 11:51

Ciuin wrote:

> On Mar 27, 11:55 am, "Ciuin" <c...@gmx.de> wrote:
>> Hi all,
>>
>> I need to mail() emails with user input that does contain non-ascii
>> (umlauts, accents) and non-latin (cyrillic) characters in the
>> "Subject:" and "From:" headers. I understand that they are typically
>> encoded in UTF8 like this:
>>
>> =?UTF-8?B?w5Z0emkg0J/RgNC40LLQtdGC?=
>>
>> but I cannot find a PHP function to encode the input string in this
>> way. utf8_encode gives me garbled char soup, so what do you use?
>>
>> Thanks.
>
> Ah well, bad thinking on my part.

Was it?
Not really.

Encoding/charsets/headers/content-type/UTF/unicode/etc ALWAYS gives me a
headache. :-/
Confusing stuff, especially when you have to consider a whole range of
receiving clients (different browsers, emailclients, etc).

Regards,
Erwin Moller

>
> Instead of utf8_encode I need base64_encode, of course (as the "...?
> B?..." in the code tells me). So this:
>
> $from = "From: =?UTF-8?B?" . base64_encode($_POST['name']) . "?= <" . $
> $_POST['email'] . ">\n";
>
> produces a correctly encoded header. Same for subject.
>
> Hope it helps someone.

 

Navigation:

[Reply to this 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

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