0

我试图使用 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;
            }
        }
    }
} 

一切正常,但我注意到返回内容需要很长时间。

它是提取全部内容还是仅提取消息结构?或者有没有办法检测附件是否存在?

谢谢。

4

0 回答 0