From 573436451724b8af5d6359227e50036996e55326 Mon Sep 17 00:00:00 2001 From: Alexander Weinhold Date: Fri, 1 Sep 2017 18:17:16 +0200 Subject: [PATCH] change tag to something unlikely, be less pessimistic about errors --- imap/imap.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/imap/imap.go b/imap/imap.go index a2e83e1..164a3cf 100644 --- a/imap/imap.go +++ b/imap/imap.go @@ -12,7 +12,7 @@ import ( ) const ( - tag = ". " + tag = "<> " other = "* " maxRead = 11000000 timeout = 3000 // ms @@ -115,12 +115,13 @@ func searchUnseen(c *connection) stateFunc { } func fetch(c *connection, ids []int) stateFunc { + nErrs := 0 for _, id := range ids { c.write(cmd(fmt.Sprintf("uid fetch %d body[]", id))) - if c.err == nil { + if len(c.err) == nErrs { s := c.read("uid fetch of " + strconv.Itoa(id)) s = strings.TrimRight(s, ")\r\n") - if c.err == nil { + if len(c.err) == nErrs { mail, err := parseMail(s) if err == nil { c.unreadMails = append(c.unreadMails, mail) @@ -129,6 +130,7 @@ func fetch(c *connection, ids []int) stateFunc { } } } + nErrs = len(c.err) } return logout }