Re: [PHP-I18N] Re: mb_send_mail() does not send UTF-8 encoded messages properly

[email protected] (Anastas Giokov)
Newsgroups php.i18n
Message-ID <[email protected]>
Motin wrote:
> Anastas Giokov <agiokov <at> gmail.com> writes:
>
>   
>> I am trying to send UTF-8 encoded e-mail message with mail() function,
>> overloaded by mb_send_mail(). The following message is recorded in error
>> log:
>>
>> PHP Warning:  mb_send_mail() [<a
>> href='function.mb-send-mail'>function.mb-send-mail</a>]: Unsupported
>> charset &quot;&quot;utf-8&quot;&quot; - will be regarded as ascii in {file}
>>
>> The message is sent ASCII encoded and is garbled.
>>
>> mb_language returns 'neutral' as it should be for UTF-8.
>>
>> I'm using PHP 5.1.6 / Apache 2.2.3 on Debian testing.
>>
>> Anastas
>>
>>     
>
> Hi,
>
> I have the exact same problem.
>
> The php sources throwing this error is (from
> http://php5.sourcesdb.com/r.php?num=1960)
>
>    if (_tran_cs == mbfl_no_encoding_invalid) {
>    php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported charset \"%s\" -
> will be regarded as ascii", charset);
>    _tran_cs = mbfl_no_encoding_ascii;
>    }
>
> It seems that the mb_string-extension does not strip away the quotations on
> "utf-8". Then, since "\"utf-8\"" != "utf-8" the script endocing is not
> considered valid.
>
> But I cannot see where it gets the idea from that the chosen encoding is "utf-8"
> with quotation marks... In php.in all I've got is mbstring.internal_encoding =
> UTF-8 (without quation as one can see)
>
> Do you have any new light to shed over the subject?
>
> Cheers,
>
> Fredrik
>
>   
I made some additional tests and found a workaround for the problem:
turned 'off' function overload for mail(). This works since no character
encoding translation is involved.

I found where the additional quotes are coming from - the mime header of
the message to send is:

Content-Type: text/plain; charset="UTF-8"

When changed the code to send:

Content-Type: text/plain; charset=UTF-8

the error disappeared along with the message body :) Obviously the
encoding is derived from this header.

I will continue to investigate the problem, but it would be better if
somebody from the code authors take care of this problem.

Regards,
Anastas
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.