nilFM

unix style email with mblaze

intro

Email is pretty cool. It's an ancient (by computing standards) communications protocol, versatile, and moderately efficient. One of the best parts about it is that you can use just about any program you want to recieve, read, compose, and send mail. I used Mutt for years, with stints on Thunderbird, webmail, and various mobile mail clients. The past few weeks, I've settled on a workflow that I'm really enjoying -- mblaze with isync/mbsync and msmtp. It turns out to be a very elegant and usable setup.

the basic structure

The UNIX way is to prefer compositions of small tools, each of which are well suited to a single focused task, to monolithic programs that try too hard to do too much and fail to deliver on those promises. In this case, I'm using a triad of single-purpose tools to tackle my email:

mbsync syncs mail from Zoho to a local folder hierarchy on my machine. I have a script which runs in the background that calls mbsync every 5 minutes to sync my mailboxes and show alerts if new mail has arrived. I also have it hooked up to a keybinding to manually sync. msmtp can deliver outgoing mail by passing it to the Zoho SMTP server. Both of these tools have very simple configuration files (see here and here) which make them very easy to get up and running. Configuring mblaze is also very simple, so these tools are well suited to each other.

mblaze and beyond

For the past year or so, I'd been using Mutt with mbsync to keep local copies of my mail, but a few issues with my Mutt workflow were bothering me, so I started looking at mblaze, which I had been briefly exposed to in the past as it was mentioned on the Void Linux news a few years ago. mblaze is actually a suite of utilities itself, designed to be used in pipelines and scripts and prime to build a personalized mail-user-agent out of.

Of course, that's what I did. My needs are simple, so I currently only have 3 wrappers around the base functionality of mblaze (2 of which are pretty trivial). The first, mcheck is a combination of two pipelines mentioned in the mblaze manual page -- it lists all the mail in the given mailbox, incorporating new mail into the cur directory. The mailbox defaults to INBOX, and is relative to the MBOX_ROOT environment variable, which I set to /home/nilix/lib/mail/zoho (the same root that mbsync syncs mail to)

The second tool is the most complex -- mread. This takes a numerical argument corresponding to a message listed via mcheck, and shows the headers of the mail, its plaintext part (if any -- some corporate email spam is all in HTML with no plaintext alternative, which is annoying), and a summary of all the attachments on the message and their mimetypes; The message is marked as seen. A propmt is then given which allows the user to select an attachment to view or download, to reply to or forward the mail, to mark or unmark it as trashed, or quit. Replying and forwarding use mcom and friends (which in turn shell out to your text editor of choice for the actual composition phase), which is a pretty seamless experience.

The third tool, mtrash, is just a wrapper around mpick and mrefile which moves all mail marked trashed in the given mailbox (relative to MBOX_ROOT and defualting to INBOX, like mcheck) into the trash.

On a slightly unrelated note, as I've mentioned before, I use mail2mms on my Uberspace slice to send email alerts to my phone, and only read/write email from my laptop, instead of using a mobile email client.

go forth and write mail

The really nice thing about this setup is that it's so composible I can use it from within plain terminals or acme, and signing, encrypting, and decrypting mail is pretty transparent and effortless. I have my tools under a common repository, mblast, and they are in the public domain so if you want to get started with mblaze feel free to take them and run. Regardless of your mail client or provider, use email! It's decentralized, supports privacy (not anonymous unless you use throwaway accounts -- the sender and recipient of encrypted mail are still visible in the headers), and there are options out there for everybody! Feel free to drop me a line; I'm always glad to make a new pen-pal!