Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOTIFY support #314

Open
Mic92 opened this issue Dec 5, 2019 · 3 comments
Open

NOTIFY support #314

Mic92 opened this issue Dec 5, 2019 · 3 comments

Comments

@Mic92
Copy link

Mic92 commented Dec 5, 2019

It would be cool if the NOTIFY extension would be implemented, which allows
to watch for changes for multiple mailboxes over a single TCP connection.
It is supported by dovecot for example.

Here is an example that I hacked together in python3.7.5 (with ugly monkey patching):

import imaplib

client = imaplib.IMAP4('mydomain.com')
client.debug = 4
client.starttls()
imaplib.Commands["NOTIFY SET"] = ("AUTH",)

rv, data = client.login("myusername", "mypassword")
typ, dat = client._simple_command('NOTIFY SET', "(subscribed (FlagChange SubscriptionChange MessageNew MessageExpunge))")
print(client.readline())

This is the debug output

  24:02.62 > b'MHJN1 STARTTLS'
  24:02.68 < b'MHJN1 OK Begin TLS negotiation now.'
  24:02.74 > b'MHJN2 CAPABILITY'
  24:02.85 < b'* CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ AUTH=PLAIN AUTH=LOGIN'
  24:02.85 < b'MHJN2 OK Pre-login capabilities listed, post-login capabilities have more.'
  24:02.85 > b'MHJN3 LOGIN [email protected] "xxxxxxx"'
  24:04.76 < b'* CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY LITERAL+ NOTIFY SPECIAL-USE'
  24:04.76 < b'MHJN3 OK Logged in'
  24:04.76 > b'MHJN4 NOTIFY SET (subscribed (FlagChange SubscriptionChange MessageNew MessageExpunge))'
  24:04.82 < b'MHJN4 OK NOTIFY completed (0.005 + 0.000 + 0.004 secs).'
b'* STATUS INBOX (UNSEEN 1)\r\n'

This would allow to write simple & efficient notification daemons.

@Mic92 Mic92 changed the title NOTIFY SET NOTIFY SET support Dec 5, 2019
@emersion emersion changed the title NOTIFY SET support NOTIFY support Dec 5, 2019
@emersion
Copy link
Owner

emersion commented Dec 5, 2019

RFC: https://tools.ietf.org/html/rfc5465

@Kilehynn
Copy link

Hello,

I was wondering if there was any news about this extension ?

@emersion
Copy link
Owner

Patches welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants