20,359
社区成员
发帖
与我相关
我的任务
分享
<?php
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to mail: ' . imap_last_error());
$struct = imap_fetchstructure($inbox,$uid,FT_UID);
$existAttachments = existAttachment($struct);
function existAttachment($part){
if (isset($part->parts)){
foreach ($part->parts as $partOfPart){
existAttachment($partOfPart);
}
}
else{
if (isset($part->disposition)){
if ($part->disposition == 'attachment'){
echo '<p>' . $part->dparameters[0]->value . '</p>';
// here you can create a link to the file whose name is $part->dparameters[0]->value to download it
return true;
}
}
}
}
?>