<? $structure = imap_fetchstructure($mailbox,$id); $parts = count($structure->parts); $body = imap_fetchbody($mailbox,$id,1); if($structure->parts[0]->parameters[0]->value!='' AND $structure->parts[0]->parameters[0]->value!='UTF-8'){ if($structure->parts[0]->parameters[0]->value=='default'){ $structure->parts[0]->parameters[0]->value = 'windows-1251'; } $body = iconv($structure->parts[0]->parameters[0]->value,'utf-8',$body); }else{ if($subj[1]->charset!=''){ $body = iconv(trim($subj[1]->charset),'utf-8',$body); }else{ $body = iconv(trim($subj[0]->charset),'utf-8',$body); } } $body = imap_qprint($body);