How to find only “new” messages when using PHP's IMAP functions for a POP3 mailbox?

只愿长相守 提交于 2019-11-29 16:32:29

Well found this..

Basically, pop3 protocol doesn't support this function. However, you can implement this with message-id. Message-Id is an unique identifier of email on POP3 server. Your application can get message-id of a specified email by GetMsgID method of POPMAIN object.

Firstly, your application should record message-id of email retrieved to a local message-id list. Next time before you retrieve email, compare local message-id with remote message-id. If this message-id exists in your local message-id list, then it is old, otherwise it is new.

Although I'm pretty sure I read before that not all clients will returns the message_id... anyone know if this is correct?

Welisson Carlos Dias

This worked for me:

$result = imap_search($connection, 'UNSEEN');

Reference: https://www.electrictoolbox.com/php-imap-unread-messages/

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!