[Twisted-Python] imap and noop

Jean-Paul Calderone exarkun at divmod.com
Wed Jul 8 10:58:46 EDT 2009

On Wed, 08 Jul 2009 15:33:49 +0100, Darren Syzling <dsyzling at gmail.com> wrote:
>I'm new to twisted and was experimenting trying to create an imap server
>based on the example within Twisted Network Programming Essentials. My
>test client is Thunderbird.
>I'm wondering if anyone has had any experience handling the 'noop'
>command here's my scenario:
>- I have two unread messages in a folder, I open thunderbird, select
>this folder and then select trash - trash has no messages.
>- Each folder is selected and fetched with a uid:*
>- My server correctly responds.
>- Each time I now select the trash folder since it didn't have any
>messages to start with Thunderbird continues to send noops. I think it's
>waiting for my server to respond with exists or recent.
>- Ok so I continue, I read and delete the two messages in my folder,
>Thunderbird issues copy commands, I dutifully flag the messages in the
>folder as \Deleted and the messages are added (via addMessage) to the
>Trash folder with the correct flags - \Seen.
>- But now if I select the Trash folder thunderbird just sends noop -
>again it looks like it wants the server to send back exists or recent to
>indicate there are now messages in that folder - even though it's just
>copied stuff to the folder.
>If in the above scenario I don't select the trash folder first and
>messages are deleted everything works fine - but in that case the client
>is sending fetch uid:*. It seems that if Thunderbird detects no messages
>in a folder it will noop until the server responds with an update.
>Anyone seen or worked around this? Are there hooks in the imap framework
>to allow a mailbox or my mailserver to respond to noops? I don't appear
>to have any mailbox listeners subscribed and I tried overriding the noop
>for my derived IMAP4Server protocol derived class - but to no avail.

You may want to use the IMailboxListener implementation on IMAP4Server to
handle this case (IMAP4's complicated, I'm not sure this is the right
direction to pursue, but it's *a* direction :).

The modeChanged, flagsChanged, and newMessages methods on IMAP4Server are
intended for use by your mailbox implementation.  In this case, it sounds
like you want to have your trash mailbox call newMessages when the messages
are copied into it.  This requires a bit of legwork on your part, keeping
track of the IMAP4Server protocol (or possibly more than one!) from the
mailbox code, but the result should be that when Thunderbird sends those
NOOPs, the server responds with one or both of EXISTS or RECENT (untagged).


More information about the Twisted-Python mailing list