PHP IMAP INBOX message loop
I have written a PHP script which connects to my Gmail account and loo开发者_Python百科ps messages inside the "INBOX" folder. However, I want to learn the "labels" of each message that exist in the INBOX folder. In other words, I want to learn which other IMAP folder does each message in the inbox exist? In this way, I am planning to write a small stats php script which will show me messages from each label. For example, My Gmail IMAP folders are;
- INBOX (75 messages)
- Personal (21839 messages)
- Business (129 messages)
- Friends (4321 messages)
- Facebook (293 messages)
All those 75 messages in the INBOX are also labeled with other folders. I want to show how many of those 75 messages belong to "Personal" or "Business" folder also. Is this possible with PHP imap functions?
Thanks.
Imap store messages in a mailboxes, a different mailbox for each folder. You need to check the folders separately, look this sample:
$boxes = imap_getmailboxes($mbox, "{mail.domain.com}", "*");
foreach($boxes as $val) {
$piece1 = explode("}", $val->name);
$piece2 = explode(".", $piece1[1]);
if (empty($piece2[1])) {echo '<div><b>Inbox</b></div>';}
}
精彩评论