function test($strHead){
if(ereg("=\?.{0,}\?[Bb]\?",$strHead)){
$arrHead=split("=\?.{0,}\?[Bb]\?",$strHead);
while(list($key,$value)=each($arrHead)){
if(ereg("\?=",$value)){
$arrTemp=split("\?=",$value);
$arrTemp[0]=base64_decode($arrTemp[0]);
$arrHead[$key]=join("",$arrTemp);
}
}
$strHead=join("",$arrHead);
}
return $strHead;
}
function is_utf8($string) {
// From https://w3.org/International/questions/qa-forms-utf-8.html
return preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string);
}
for($i=$tot;$i>0;$i--)
{
$head=$obj->getHeaders($i); // Get Header Info Return Array Of Headers **Array Keys are (subject,to,toOth,toNameOth,from,fromName)
//echo "Subjects :: ".$head['subject']."<br>";
$s=test($head['subject']);
if(is_utf8($s)=='1'){
echo iconv('UTF-8','gb2312',$s) ;
}else{
echo $s;
}
echo "<br>";
echo "base :: ".iconv("GB2312", "utf-8", base64_decode('5rWL6K+V'))."<br>";
echo "TO :: ".$head['to']."<br>";
echo "To Other :: ".$head['toOth']."<br>";
echo "ToName Other :: ".$head['toNameOth']."<br>";
echo "From :: ".$head['from']."<br>";
echo "FromName :: ".$head['fromName']."<br>";
echo "<br><br>";
echo "<br>*******************************************************************************************<BR>";
echo $obj->getBody($i); // Get Body Of Mail number Return String Get Mail id in interger
$str=$obj->GetAttach($i,"./"); // Get attached File from Mail Return name of file in comma separated string args. (mailid, Path to store file)
$ar=explode(",",$str);
foreach($ar as $key=>$value)
echo ($value=="")?"":"Atteched File :: ".$value."<br>";
echo "<br>------------------------------------------------------------------------------------------<BR>";
//$obj->deleteMails($i); // Delete Mail from Mail box
}
function test($strHead){
if(ereg("=\?.{0