Hi, I am creating a small webmail interface, but I have a small problem with attachments:
I succeed in downloading the file (the filename and MIME type is correct), but all the files that I download are corrupt, I can't open any of them. Here's the code, any help would be appreciated!
Regards Bruno
<?
if ($link = imap_open("{my.mail.server:110/pop3}", "login", "password")) {
$struct=imap_fetchstructure($link,$num);
$parts=$struct->parts;
$MIME=$parts[$part]->subtype;
$props=$parts[$part]->parameters;
while (list ($key, $val) = each ($props)) {
if ($val->attribute=='NAME') {$filename=$val->value;}
}
header ("Content-type: $MIME");
header ("Content-Disposition: attachment; filename=$filename");
header ("Content-Transfer-Encoding: binary");
echo imap_fetchbody //echo'ing the biniary data($link,$num,$part+1);
//echo "$MIME<br>$filename";
}
else {echo "er kon geen verbinding worden gemaakt";}
?>