Offline email with aerc and vsync
2023-02-14 on adnano.coaerc is a pretty good email client for the terminal. I use aerc almost every day to read emails, review patches, and participate in mailing lists. Unfortunately, aerc's IMAP implementation requires you to always be online to view messages. Every time a message is opened, it is fetched from the IMAP server before being displayed. This incurs a small but noticeable delay. aerc can also be slow to start as it must fetch the message list from the server on startup.
Fortunately, we can take advantage of aerc's Maildir support to read email offline. This makes starting up aerc and opening messages a breeze. We can then use another tool to keep our maildir in sync with the IMAP server.
vsync is a tool that syncs your mail to a local directory in Maildir++ format. It is simple to configure and easy to use. For example, my configuration looks something like this:
[Personal]
local = "~/mail"
remote = "imap.example.net"
user = "user@example.com"
password = "..."
The password can also be retrieved with a command if you are using a password manager.
After configuration, run vsync
once to fetch mail from the IMAP server and
populate the maildir.
Now that we have a maildir, we need to configure aerc to read mail from it.
Thankfully, this is easy to do by updating accounts.conf
:
[Personal]
source = maildirpp://~/mail
check-mail = 30s
check-mail-cmd = vsync
outgoing = smtps+plain://user%40example.com@smtp.example.net
# ...
This tells aerc to read from the maildir and to run vsync
every 30 seconds to
sync new mail. Eventually, running vsync
periodically won't be necessary as
support for running it as a daemon is planned. aerc will continue to send
messages using SMTP.