Ruby IMAP “changes” since last check

后端 未结 2 1029
暗喜
暗喜 2021-02-10 14:51

I\'m working on an IMAP client using Ruby and Rails. I can successfully import messages, mailboxes, and more... However, after the initial import, how can I detect any changes t

2条回答
  •  半阙折子戏
    2021-02-10 15:01

    There is an IMAP extension for Quick Flag Changes Resynchronization (RFC-4551). With this extension it is possible to search for all messages that have been changed since the last synchronization (based on some kind of timestamp). However, as far as I know this extension is not widely supported.

    There is an informational RFC that describes how IMAP clients should do synchronization (RFC-4549, section 4.3). The text recommends issuing the following two commands:

    tag1 UID FETCH :* 
    tag2 UID FETCH 1: FLAGS
    

    The first command is used to fetch the required information for all unknown mails (without knowing how many mails there are). The second command is used to synchronize the flags for the already seen mails.

    AFAIK this method is widely used. Therefore, many IMAP servers contain optimizations in order to provide this information quickly. Typically, the network bandwidth is the limiting factor.

提交回复
热议问题