GUIs are nice, but command line mail clients make me more productive with reduced stress on the human side of the UI (i.e. my fingers and wrists). On Linux, Pine, and now alpine have served me well for many years, despite some limitations in an increasingly HTML-bloated email world. The following is one issue that has annoyed me, related to some behind-the-scenes upgrades by my email provider some years ago. As usual, the the troubleshooting journey proved to be instructive about the behaviour of IMAP servers — specifically my provider’s implementation (based on Dovecot) of session timeouts.
The scenario: you’re logged in, browsing your INBOX or composing an email and suddenly get the error:
MAIL FOLDER "INBOX" CLOSED DUE TO ACCESS ERROR
which forces you to re-open the folder. Additionally, when replying to email, once the INBOX is closed, flag updates (such as Answered) don’t apply any more. This seemed to happen randomly, and for other folders I have open (not just in the INBOX). The error at first suggests a lock contention, but research suggested it was actually the connection being closed, and that forcing more frequent mail checks would help.
The first step was to establish a client-independent IMAP connection and leave it idle:
$ time openssl s_client -connect mailprovider:993 -quiet
... [SSL preamble snipped out ]
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
a1 LOGIN MYUSERNAME@DOMAIN MYPASSWORD
a1 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS] Logged in
a2 EXAMINE INBOX
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft $Forwarded)
* OK [PERMANENTFLAGS ()] Read-only mailbox.
* 955 EXISTS
* 0 RECENT
* OK [UNSEEN 1] First unseen.
* OK [UIDVALIDITY 1156786977] UIDs valid
* OK [UIDNEXT 106677] Predicted next UID
* OK [HIGHESTMODSEQ 1] Highest
a2 OK [READ-ONLY] Select completed.
read:errno=0
real 2m24.046s
user 0m0.034s
sys 0m0.008s
$
(BOLD text represents commands from my end)
Continue reading →