4

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.

Community
  • 1
  • 1
benchpresser
  • 2,171
  • 2
  • 23
  • 41
  • 1
    It will compare UIDS available on server with the ones it has locally, and remove ones that don't exist anymore, and hide ones with the \Deleted flag. – Max May 07 '15 at 12:50

1 Answers1

1

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

Community
  • 1
  • 1
Nameless One
  • 1,615
  • 2
  • 23
  • 39
  • 2
    Actually, if you have an open connection to the server for the folder, the server should send an unsolicited FETCH response indicating that the \Deleted flag was set, followed by an EXPUNGE response indicating that the message is really gone. You can listen for these events using a [MessageChangedListener](https://javamail.java.net/nonav/docs/api/javax/mail/event/MessageChangedListener.html) and a [MessageCountListener](https://javamail.java.net/nonav/docs/api/javax/mail/event/MessageCountListener.html). If you're offline, you can use UIDs to resynchronize your view when you go online. – Bill Shannon May 07 '15 at 23:44