1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
$mbox = open_mailbox($mail_pop_server, $mail_login, $mail_pass);
$structure = imap_fetchstructure($mbox,$msgid);
# piece jointe #
$return_content = imap_fetchbody($mbox,$msgid, $partnumber+1);
$anencode = $structure->parts[$partnumber]->encoding;
$atype = $structure->parts[$partnumber]->type;
if($atype == "") $atype = 0; // Text
$asubtype = $structure->parts[$partnumber]->subtype;
if($asubtype == "") $asubtype = 'PLAIN';
$attach_type = $mimetype[$atype]."/".$asubtype;
if($anencode == 1) $return_content = imap_8bit($return_content);
if($anencode == 2) $return_content = imap_binary($return_content);
if($anencode == 3) $return_content = imap_base64($return_content);
if($anencode == 4) $return_content = imap_qprint($return_content);
$nom_fichier = $structure->parts[$partnumber]->parameters[0]->value;
close_mailbox($mbox);
header("Content-type: $attach_type");
header("Content-Disposition: attachment; filename = $nom_fichier" );
echo $return_content; |
Partager