Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
791 views
in Technique[技术] by (71.8m points)

email - How to find only "new" messages when using PHP's IMAP functions for a POP3 mailbox?

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?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...