Send Unicode attachment with mail
Posted: Fri May 30, 2008 8:18 pm
Hi,
from MacOS X, I send data (one char only just to test) to my php script (to the variable $name) .
I verify on Mac the unichar I send is 'é' (e lowercase with acute accent) which printed on Mac with NSLog as %d is 233. Well, on my php I echo the ord($name[0]) and it properly shows 233. Perfect.
Now I have to send an email containing a text file as attachment containing that $name.
So, in my multiple header I do:
$attachment = chunk_split(base64_encode($name));
$message .= "Content-type: application/octet-stream; name=\"MyTextFile.txt\"\n";
$message .= "Content-disposition: attachment\n";
$message .= "Content-transfer-encoding: base64\n\n";/
$message .= $attachment . "\n\n";
Well, I receive an email with the attachment (a text file), but this text file contains an 'È' (uppercase E with grave accent). Wrong. I tried several conversions with mb_convert_encoding unsuccessfully.
What do I miss? Is anyone who knows how to fix this trouble? Which conversion should I do?
from MacOS X, I send data (one char only just to test) to my php script (to the variable $name) .
I verify on Mac the unichar I send is 'é' (e lowercase with acute accent) which printed on Mac with NSLog as %d is 233. Well, on my php I echo the ord($name[0]) and it properly shows 233. Perfect.
Now I have to send an email containing a text file as attachment containing that $name.
So, in my multiple header I do:
$attachment = chunk_split(base64_encode($name));
$message .= "Content-type: application/octet-stream; name=\"MyTextFile.txt\"\n";
$message .= "Content-disposition: attachment\n";
$message .= "Content-transfer-encoding: base64\n\n";/
$message .= $attachment . "\n\n";
Well, I receive an email with the attachment (a text file), but this text file contains an 'È' (uppercase E with grave accent). Wrong. I tried several conversions with mb_convert_encoding unsuccessfully.
What do I miss? Is anyone who knows how to fix this trouble? Which conversion should I do?