• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D19-May-2019266

LICENSEH A D19-May-20191.1 KiB

README.mdH A D19-May-2019957

client.goH A D19-May-20192.4 KiB

command.goH A D19-May-2019286

example_test.goH A D19-May-20191.7 KiB

idle.goH A D19-May-2019184

response.goH A D19-May-2019709

server.goH A D19-May-2019968

README.md

1# go-imap-idle
2
3[![GoDoc](https://godoc.org/github.com/emersion/go-imap-idle?status.svg)](https://godoc.org/github.com/emersion/go-imap-idle)
4
5[IDLE extension](https://tools.ietf.org/html/rfc2177) for [go-imap](https://github.com/emersion/go-imap).
6
7## Usage
8
9### Client
10
11```go
12// Let's assume c is an IMAP client
13var c *client.Client
14
15// Select a mailbox
16if _, err := c.Select("INBOX", false); err != nil {
17	log.Fatal(err)
18}
19
20idleClient := idle.NewClient(c)
21
22// Create a channel to receive mailbox updates
23updates := make(chan client.Update)
24c.Updates = updates
25
26// Start idling
27done := make(chan error, 1)
28go func() {
29	done <- idleClient.IdleWithFallback(nil, 0)
30}()
31
32// Listen for updates
33for {
34	select {
35	case update := <-updates:
36		log.Println("New update:", update)
37	case err := <-done:
38		if err != nil {
39			log.Fatal(err)
40		}
41		log.Println("Not idling anymore")
42		return
43	}
44}
45```
46
47### Server
48
49```go
50s.Enable(idle.NewExtension())
51```
52
53## License
54
55MIT
56