You are here: Re: mail() encoding problems « PHP Programming Language « IT news, forums, messages
Re: mail() encoding problems

Posted by Manuel Lemos on 08/22/07 21:23

Hello,

on 08/22/2007 04:00 PM amygdala said the following:
> <snip>
>
>> The only thing really wrong is that you should not send 8 bit encoded
>> messages as many mail gateways do not supported. Instead of 8 bit you
>> should use quoted-printable encoding.
>
> Alright, I didn't know this. This makes sense. Cause like I said, even
> without me encoding it as utf-8, the problem randomly occured. Perhaps the
> apparent random appearance of strange characters and/or missing of
> diactrical characters could be explained due to the fact that subsequent
> mail messages can get send through different mail gateways to their
> end-destination, just like a tcp packets? Or is that not correct? Not very
> imporant for me to get answered, but it would help me get a better
> understanding of things. ;-)

No, the diacritical characters appear when transform your text to UTF-8
.. UTF-8 still uses 8 bits per character. If you read the mail message
that is sent you see those characters because whatever console or text
display program you are using does not decode UTF-8 and show the correct
characters.


>> You can also have 8 bit characters in the headers but they must be
>> encoded with q-encoding to avoid the same problem with the message body.
>
> I probably won't be needing that at this point in time. But that's good to
> know also.
>
>> This is a bit complicated to encode by hand. I use this MIME message
>> composing and sending class to take care of all that for me.
>>
>> http://www.phpclasses.org/mimemessage
>>
>
> Although I only had a quick glance at your class, and it probably does the
> job well, it looks like a bit of overkill for my purposes. So in conclusion,
> is it fair to say that I only need to change:
>
> $headers .= 'Content-Transfer-Encoding: 8bit' . LF;
>
> to
>
> $headers .= 'Content-Transfer-Encoding: quoted-printable' . LF;
>
> and leave
>
> $headers .= 'Content-Type: text/plain; charset=iso-8859-1' . LF;
>
> as is?

No, you need actually encode your body data using quoted-printable. Just
changing the headers does not do it. Using quoted-printable 8 bit and
non-printable characters are transformed in escaped sequences of ASCII
(7 bit) characters.


--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

 

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

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