我试图使用PHP IMAP函数读取标题并保存到mysql数据库中。
检查附件的示例代码
$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>';
return true;
}
}
}
}
一切正常但我注意到返回内容需要很长时间。
是否会提取整个内容或仅提取消息结构?或者有没有办法检测附件是否存在?
感谢。