$inbox = imap_open("{".HOSTNAME.":993/imap/ssl/novalidate-cert}INBOX", EMAIL_USER, EMAIL_PASSWORD);
$emails = imap_search($inbox,'all');
这就是我正在做的事情。但这是阅读所有邮件。假设我想要读取邮件的文件夹名称是“temp”。我该如何只阅读此文件夹中的邮件?
答案 0 :(得分:0)
您所要做的就是选择要打开的文件夹。 此代码将帮助您获取文件夹列表:
$list = imap_getmailboxes($imap_stream, "{imap.HOSTNAME.com:993/imap/ssl}", "*");
if (is_array($list)) {
foreach ($list as $key => $val) {
echo "($key) ";
echo imap_utf7_decode($val->name) . ",";
echo "'" . $val->delimiter . "',";
echo $val->attributes . "<br />\n";
}
} else {
echo "imap_getmailboxes failed: " . imap_last_error() . "\n";
}
然后你所要做的就是
$inbox = imap_open("{".HOSTNAME.":993/imap/ssl/novalidate-cert}CHANGEME", EMAIL_USER, EMAIL_PASSWORD);
$emails = imap_search($inbox,'all');