ab,
You have to transverse the parts in message structure. This is what I was pointing out earlier on being able to get the charset of the individual parts. Below is an updated getPart function in class.pop3.php
function getPart($mid,$mimeType,$encoding=false,$struct=null,$partNumber=false){
if(!$struct)
$struct=imap_fetchstructure($this->mbox, $mid);
//Match the mime type.
if($struct && strcasecmp($mimeType,$this->getMimeType($struct))==0){
$partNumber=$partNumber?$partNumber;
if(($text=imap_fetchbody($this->mbox, $mid, $partNumber))){
if($struct->encoding==3 or $struct->encoding==4) //base64 and qp decode.
$text=$this->decode($struct->encoding,$text);
$charset=null;
if($encoding) { //Convert text to desired mime encoding...
if(!strcasecmp($struct->parameters->attribute,'CHARSET') && strcasecmp($struct->parameters->value,'US-ASCII'))
$charset=trim($struct->parameters->value);
$text=$this->mime_encode($text,$charset,$encoding);
}
return $text;
}
}
//Do recursive search
if($struct && $struct->parts){
while(list($i, $substruct) = each($struct->parts)) {
if($partNumber)
$prefix = $partNumber . '.';
if(($text=$this->getPart($mid,$mimeType,$encoding,$substruct,$prefix.($i+1))))
return $text;
}
}
//No luck.
return false;
}For example to get plain text use $body = $this->getpart($mid,'TEXT/PLAIN',$this->charset) where $this->charset is the desired enconding.