如何找到只有“新的”使用PHP的IMAP功能为POP3邮箱的消息? [英] How to find only "new" messages when using PHP's IMAP functions for a POP3 mailbox?

查看:212
本文介绍了如何找到只有“新的”使用PHP的IMAP功能为POP3邮箱的消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP的IMAP功能从POP3邮箱中检索邮件想知道有什么办法可以告诉新的消息,除了旧的?

I'm using PHP's IMAP functions to retrieve messages from a POP3 mailbox & was wondering is there any way to tell the new messages apart from the old ones?

不幸的是,我不能只是删除那些被检索,因为他们需要留在邮件服务器,所以我现在想知道每一个连接的时间,我怎么只能检索新的,或者可以告诉新的,除了以前我已经检索过的旧的?

Unfortunately I cannot just delete the ones that are retrieved as they need to stay on the mail server, so I'm now wondering that each subsequent time I connect, how can I just retrieve the new ones OR be able to tell the new ones apart from the old ones I have already retrieved previously?

我知道每个消息都附有UID,我可以使用这个..但是我已经阅读,如果消息被删除,这可以改变;因为邮件可能会从服务器中删除。

I know that each message has a UID attached to it & I could use this.. however I've read that this can change if the messages are deleted; as the messages may be deleted from the server down the track.

推荐答案

发现这个..


基本上,pop3协议不支持此功能。但是,
可以用message-id来实现。 Message-Id是
POP3服务器上的电子邮件的唯一标识符。您的应用程序可以通过GetMsgID
POPMAIN对象的方法获取指定电子邮件的消息。

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.

首先,您的应用程序应记录检索到的电子邮件的邮件ID一个本地的
message-id列表。下次检索电子邮件之前,请将本地消息ID
与远程消息标识进行比较。如果您的
本地消息id列表中存在此消息ID,那么它是旧的,否则它是新的。

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.

虽然我很确定我之前读过,并不是所有的客户端都会返回message_id ...任何人都知道这是否正确?

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

这篇关于如何找到只有“新的”使用PHP的IMAP功能为POP3邮箱的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆