benchpresser
benchpresser

Reputation: 2188

Fetching mails with IMAP, get deleted messages

I have a mail account with 5000 messages, the old ones are 4 years old. I login to that account with a web interface and with thunderbird. I delete a very old mail in the web interface. Then I press refresh (get mails) on the thunderbird without relogin. Thunderbird immediately deletes the message. How can detect thunderbird the deleted message so quickly? I have to implement so mechanism in java (java mail api), I think I have to fetch all mails, and have to store already fetched mails in the local, then I have to compare each one by-one. As I know, the message id property is not secure, hence it can be changed when I move one message to another, they are not secure. The best way is using message id stored in the header or using a custom cache mechanism as stated in:

Mailing with IMAP: How to detect that a message has been moved from one folder to another?

As a result, how can we informed about deleted or moved messages so quickly? And how detects thunderbird new emails? Does it store last stored message id? But for the deleted old messages or moved messages, the only option is comparing all folder with local storage, am I wrong?

My idea, I will check the thunderbirds debug mode and see what happens in the lower layer.

Upvotes: 4

Views: 2027

Answers (1)

Nameless One
Nameless One

Reputation: 1646

When the messages are deleted, the server would send an EXISTS response, after which the client can do a FETCH or UID FETCH to determine which messages were deleted, by comparing UID values of messages it has to those on the server. See https://www.rfc-editor.org/rfc/rfc3501#section-7.3.1

Upvotes: 1

Related Questions