emersion / emersion/go-imap

NOTIFY support

Open
#314 4 comments 5 reactions 0 assignees View on GitHub
enhancement extension
Dominant language
Go
Stars
2.3k
Forks
360
Avg merge
1d 16h
Merged PRs (30d)
1

Description

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 xxxx@xxxxxxx.xx "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.

Contributor guide

Open the contributing guide

Research direction

Start by locating the repository's IMAP command and unsolicited-response handling, then compare the requested NOTIFY SET behavior with the example and its multiple-mailbox notification use case. Done means the NOTIFY extension is implemented for the supported client/server behavior and can deliver the requested mailbox events over one TCP connection.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.