Distinguish between IMAP errors and network failures

The network errors could sometimes be remedied by simply reconnecting, which is
different from stuff like "hey, the IMAP server told us that we made a mistake".
Anyway, this is supposed to be a first step in transparently handling the netwok
annoyances without needlessly disturbing the user.

REVIEW: 116884
Merge branch 'refactor-network-errors'