<?php function parsepart($p,$i){ //where to write file attachments to: $filestore = 'pliki/'; //fetch part $part=imap_fetchbody($link,$msgid,$i); //if type is not text if ($p->type!=0){ //DECODE PART //decode if base64 //decode if quoted printable //no need to decode binary or 8bit! //get filename of attachment if present $filename=''; // if there are any dparameters present in this part foreach ($p->dparameters as $dparam){ if ((strtoupper($dparam->attribute)=='NAME') ||(strtoupper($dparam->attribute)=='FILENAME')) $filename=$dparam->value; } } //if no filename found if ($filename==''){ // if there are any parameters present in this part foreach ($p->parameters as $param){ if ((strtoupper($param->attribute)=='NAME') ||(strtoupper($param->attribute)=='FILENAME')) $filename=$param->value; } } } //write to disk and set partsarray variable if ($filename!=''){ } //end if type!=0 } //if part is text else if($p->type==0){ //decode text //if QUOTED-PRINTABLE //if base 64 //OPTIONAL PROCESSING e.g. nl2br for plain text //if plain text //if HTML } //if subparts... recurse into function and parse them too! foreach ($p->parts as $pno=>$parr){ parsepart($parr,($i.'.'.($pno+1))); } } return; } $msgid=1; //open resource $link=imap_open("{adres:110/pop3}INBOX", "login", "haslo"); //fetch structure of message $s=imap_fetchstructure($link,$msgid); //see if there are any parts foreach ($s->parts as $partno=>$partarr){ //parse parts of email parsepart($partarr,$partno+1); } } ?>
z góry dzięki za odpowiedź