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

不问归期 提交于 2019-12-04 15:49:58

You cannot do that in IMAP. Tracking the Message-Id header might get you half way there, but you will have to add all sorts of checks for corner cases like duplicate message IDs (yes, they are supposed to be unique) etc. Also keep in mind that what baseline IMAP gives you is a well-synchronized view to a single mailbox, not an atomic view on a set of mailboxes when combined. This means that even though a user has "moved" a message between folder A and B, it could very well be visible in both A and B for your script for a longer time period.

Some IMAP servers have added non-standard fields that you can FETCH which contain a cryptographic hash of the message payload. These are still non-standard, though.

you can try using the rfc822-header information it contains a message-id like blablabla@mail.gmail.com which should not change when mails are moved into folders. but you will have to crawl all the mail-headers of the user to sync this, at least i don't know of a way to retrieve moved messages

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