Re: Mail subject encoding breaks
| From: | Tom Worster | Date: | Tue, 12 May 2009 20:11:32 +0000 |
| Subject: | Re: Mail subject encoding breaks | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-292507@lists.php.net to get a copy of this message | ||
On 5/11/09 11:58 AM, "Thodoris" <tgol@kinetix.gr> wrote:
>
>> On 11 May 2009 at 18:25, Thodoris wrote:
>>
>>
>>> Hi gang,
>>> I am using phpmailer to send some mail notifications in an intranet
>>> I've made. This is a sample code:
>>>
>>
>>
>>> $e->Subject = "This is δφκξγκδφη garbidge κηδφκξγσ";
>>>
>>
>> Hi,
>>
>> I have had success with this in the past:
>>
>> $subject = "This is δφκξγκδφη garbidge κηδφκξγσ";
>> $e->Subject = mb_encode_mimeheader($subject, "UTF-8", "Q") ;
>>
>> Regards
>>
>> Ian
>>
>
> Thanks Ian this works in most cases but there are times that still
> breaks the subject. I have experimented with:
>
> mb_encode_mimeheader($subject, "UTF-8", "B")
>
> as well but nothing seems to be working without problems.
is it possible that in the problem cases the subject string isn't valid
utf-8?
you can check with mb_check_encoding($subject)
you can sanitize bad utf-8 with iconv("UTF-8","UTF-8//IGNORE",$subject)
though you probably won't get the string you want with that. when you don't
have other options, this will at least clean up bad encoding.