My first post was around 2003, and still the mb_mime_header is broken. It is *NOT* usable with longer subjects, and mostly unusable with anything else than japanese.
iwakura at junx dot org is also not working for me, it produces also some gargabe.
I updated my old function (the one I posted 2003) and I tested it with overlong subjects in UTF-8, ISO-2022-JP (japanese), GB2312 (simplified chinese) and EUC-KR (korean) and I got readable results in thunderbird, mail.app, outlook, etc.
<?php
function _mb_mime_encode($string, $encoding)
{
$pos = 0;
$split = 24;
while ($pos < mb_strlen($string, $encoding))
{
$output = mb_strimwidth($string, $pos, $split, "", $encoding);
$pos += mb_strlen($output, $encoding);
$_string_encoded = "=?".$encoding."?B?".base64_encode($output)."?=";
if ($_string)
$_string .= "\r\n";
$_string .= $_string_encoded;
}
$string = $_string;
return $string;
}
?>