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 }