Rediscovering Email

Please note, this article is still in progress, thus incomplete!

Preamble

“Kids these days” don’t really use email anymore. It’s me by the way, I’m kids. Sure, we email our professors, we email our resumes to potential employers, we email when the business is a tad too official for text or WhatsApp.

Email isn’t just for communication. Think about it: when all you want to do is talk to someone, are you sending them an email? When’s the last time you emailed a friend or loved one “What’s up? How’s it going?”

Email has been relegated, essentially, to administrative tasks. Emails are something you have to send. They carry an air of officiality. Definitely not the way to contact your friends.

Why is that?

Web Mail Sucks

I think our experience of writing email takes a large chunk of the blame. To be honest, it’s pretty dreadful most of the time, thanks in no small part due to the God-awful interfaces through which we interact with emails.

Web mail interfaces suck. You log into Gmail just to see that every fifth letter in your inbox is actually an ad. I’m not talking promotional mail, I’m talking a literal ad, served to you by Google, masquerading as a real message.

And tell me why Outlook needs to make hundreds of JavaScript requests, and cache a hundred megabytes of data just to show my inbox? If I’m using my laptop on the school network, chances are, I’ll be sitting there for at least ten seconds before I can even see whether I’ve got any new messages.

Oh, and I don’t know about you, but since I spent most of the day using my computer, I like to do whatever I can to prolong my ability to, like, use my eyes. A big part of that means using dark mode wherever possible, as God intended. Which brings me to my next point: dark mode in most web mail clients isn’t great.

For instance, Proton Mail provides a lovely dark interface for your inbox, just to burn your retinas off the moment you start composing a message or reading a new email. This is one area I must be fair to Outlook, however, which provides one of the nicest dark interfaces I’ve used.

For quite a few reasons, including those stated above, and of course wanting to use my own text editor to write my letters, I finally decided it was time to figure out a better way to interact with email. And as it turns out, there really is one!

Email In The Terminal?

If you know me at all, you know I’m a fiend for the terminal. If a given task is even possible to do in a command-line (or TUI) interface, then that’s the way I’ll be doing it from now on until my hands my fall off my wrists. Call it a neurodivergent stubbornness, but it’s just the only way I really like to interact with my computer.

It also happens that Helix, my text editor of choice, also runs in the terminal. Anytime I’d have to draft an email longer than a few sentences, I’d start to feel the withdrawal. Maybe Helix has really spoiled me, but the experience of manipulating text in this beautiful program is too good to not incorporate into every aspect of my life that involves writing. I’m already writing my papers and slideshows in Helix (more on that in a future post), so why not email?

First, I figured out using Thunderbird. Although it has many problems (like, tell me how there still isn’t tray support for Linux?!) using Thunderbird was otherwise a “solid” experience. Sure, Thunderbird is a GUI app, but I wasted no time in finding a pipeline for writing emails in my beloved Helix.

The extension “External Editor Revived” does exactly what it sounds like. Using it, I was able to open up email files for editing in Helix, then pipe them back to Thunderbird for review and sending. I was happy with this setup for a while despite its problems.

But as it turns out, an even nerdier way was just around the corner…

Enter Aerc

I forget where I first heard about aerc, but I’m really glad that I did! It’s a lovely little TUI email client maintained by the good people at Source Hut. It features a vim-like ex-command setup and controls. The controls are also 100% remappable, which makes my Colemak brain happy.

My favorite part, though, is the composing interface. It’s really clever: the top of the screen holds the standard headers you expect to see like From, To, and the Subject, but the part where you write the body of your letter is actually a tmux-style embedded terminal running your favorite $EDITOR!

Of course, there were quite a few hiccups in getting Helix to play along; namely, spellchecking, Markdown syntax highlighting and automatic text-wrap was a challenge. If you’re interested in the details, I’ll later be publishing a tutorial outlining step-by-step how to replicate my Helix-mail setup.

Authentication Problems

If you’re going to use an email client, you need to authenticate with your email provider. For Proton Mail, this was easy enough; the Bridge app interfaces with your encrypted inbox, and exposes IMAP and SMTP services locally. Outlook, on the other hand (especially a school/corporate policy) is a hassle.

Without getting too deep into it, it was more than one day of headache before I managed to get it working. The solution involved finding (and modifying) a Python script to authenticate and save my initial refresh token, as well as manage requesting new access tokens when they expire. I also had to gaslight Microsoft into thinking I was actually using Thunderbird (by pulling the client_id straight from the Mozilla source code).

Organizing Email

My inbox has always been disorganized. Frankly, I don’t know a single person whose inbox isn’t. And it’s understandable! The tools at our disposal aren’t particularly helpful, and most importantly, they’re not standardized. For example, we could create various folders, moving the appropriate emails as we read them. Some (emph: some) providers let you automate this, but I’ve found the filter rules to be a bit lacking. Organizing by folders also inherently limits your ability to later filter and narrow down your searches.

Tags are clearly the best way, but again, the implementation depends per-provider. Worst of all, as with most things these days, non-standard implementations mean that as soon as you’ve put all your eggs in the basket, you’re essentially locked in; unless you want to go to the colossal hassle of re-organizing your inbox playing by another provider’s rules.

Storing Email Locally

As it turns out, aerc (and other mail clients like it), besides the standard ability to read mail from an IMAP server, has another trick up its sleeve. That trick is reading mail from a local database. Now, this might not seem like a big deal. Thunderbird does this too: when you access your inbox via IMAP, Thunderbird downloads and caches all of your emails.

What I never knew, and it took messing around with aerc to learn about, is that there exist multiple standardized ways to store emails locally. What this means is that as long as you synchronize your emails to this local store, you can access them from any client!

I chose to go with a tool called mbsync, which stores mail in the standard “maildir” format, and keeps it in sync with an IMAP server. The syncing only happens when you trigger it manually – although you can easily configure another program to “listen” for new emails and sync automatically. I decided to forego this, more on why later.

Not Much Mail With A Few Tags

The best part is that once you’ve got this email database, you can pick from a host of tools and systems for indexing and organizing it. I went with a tool called notmuch, a program that’s very popular among programmers much older and more bearded than I am. notmuch indexes your maildir and basically acts as a query engine. I found the experience of using it similar to, say, SQL. The basic premise is that you write queries about your emails.

# Here's me searching for emails about GitHub authorization
notmuch search 'from:/@.*github.*/ subject:/auth\w*/'

You can also apply an arbitrary string to an email as a tag. Tags are more powerful than flags, which are IMAP compliant, but limited to only a few specific roles. notmuch allows you to create and use as many different tags as you want!

# Here's me applying the "personal" tag to
notmuch tag +personal -- 'path:personal/**'