Re: [PHP] Mail subject encoding breaks

2009-05-12 Thread Tom Worster
On 5/11/09 11:58 AM, "Thodoris"  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.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Mail subject encoding breaks

2009-05-11 Thread Thodoris



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.

I think that this solved my problems since I noticed that it works fine 
until this moment.


function mail_utf8($to, $subject = '(No subject)', $message = '', $header = '') 
{
 $header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . 
"\r\n";
 mail($to, "=?UTF-8?B?".base64_encode($subject).'?=', $message, $header_ . 
$header);
}


--
Thodoris



Re: [PHP] Mail subject encoding breaks

2009-05-11 Thread Ian
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
--



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Mail subject encoding breaks

2009-05-11 Thread Thodoris

Hi gang,
   I am using phpmailer to send some mail notifications in an intranet 
I've made. This is a sample code:


From = "aco...@host.gr";
$e->FromName = "Test";
$e->Mailer = "mail";
$e->Subject = "This is δφκξγκδφη garbidge κηδφκξγσ";
$e->CharSet = "UTF-8";
$e->Body = "H εργασία id: 122 έκλεισε με σχόλια.";


$e->AddReplyTo("supp...@kinetix.gr");
$e->AddAddress("t...@kinetix.gr");
// $e->to = array("t...@kinetix.gr");


if ($e->Send()) {
   print "Mail has been sent successfully.";
} else {
   print "Failed to send mail.".$e->ErrorInfo;
}
?>

Where mailer class is:



This script seems to work ok in a freebsd development server I have but 
a linux production machine breaks the subject's encoding for some 
unexpected reason. The subject has a mix of English and Greek characters 
that FreeBSD seems to handle like a charm.


Both machines have the same php version (5.2.9) and the scripts encoding 
is UTF-8. Iconv and mbstring are configured the same way in php.ini 
(although I am not aware whether phpmailer uses iconv or mbstring).


Has anyone had a similar experience? Is it possible that sendmail (which 
is the underlying tool) breaks the mail encoding?


Please any help would be appreciated because this is really driving me 
crazy.


--
Thodoris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php