New Email Setup With Mu4e

2016-06-22 • Last Modified: 2023-06-26 • 4 min read • Tags: Comp

This post was written on 2022-12-18 and belongs to a series of catch-up articles.

Prerequisite: basic knowledge of email protocols.

Introduction

I always loved text-based email clients, fast and effective.

After my semi-deception with Mozilla, I decided it was time to try a new email setup and maybe come back to my initial loves. I had heard of notmuch and mu and they sounded great.

Context

In terms of email clients, I’ve been using:

  • 1993 - 2001 pine ❤️
  • 2001 - 2007 exmh 😒 supported by the INRIA IT teams.
  • 2008 - 2016 Thunderbird ❤️

Notmuch and mu are basically email search engines built on top of Xapian, the C++ search library. Mu4e is an email client for emacs on top of mu.

The Setup

Yes it’s a bit involved and did require some fiddling.

  • mbsync (optional) to sync mailboxes initially.
  • imapfetch to fully retrieve incoming email, as if connecting with POP3. The reason is that, with privacy in mind, I wanted full control over my email. I didn’t want it to remain on a remote provider’s server. I can afford that as my laptop is backed up regularly. Also, since it’s a small script on top of the beautiful node-imap, it’s easy to tweak its behavior1. For the delivery, imapfetch is coupled with:
  • mu4e 💎 to read from Maildir and send emails.

Migration

Mu4e working on Maildir, I needed to import all mailboxes to that format.

Since Thunderbird supports Maildir as a backend, migrating already locally synced Thunderbird email is just a matter of changing its configuration.

For remote mailboxes, especially Gmail, I used mbsync. I now have moved away from Google and have reused mbsync regularly before the final cut.

Configuration

For a given email account, imapfetch calls maildrop with a specific configuration file. Here’s an example ~/.mailfilters/some_account_email_com:

MAILDIR="$HOME/Mail/some.account@email.com"
DEFAULT=$MAILDIR/Inbox
SPAMDIR=$MAILDIR/Junk
MARK_SPAM_READ="$HOME/bin/maildir-mark-read"
BOGO_BIN="/usr/bin/bogofilter"
BOGO_ARGS=""

cc $HOME/.mail.backup

## spam
## SEE ALSO /usr/share/bogofilter/contrib/mailfilter.example
`$BOGO_BIN $BOGO_ARGS -u`
if ($RETURNCODE == 0)
{
    cc "$SPAMDIR"
    `$MARK_SPAM_READ $SPAMDIR`
    exit
}

if (/^X-Spam-Flag:\s+YES/ || /^X-Scan-SPAM:\s+Yes/)
{
    `$BOGO_BIN $BOGO_ARGS -s`
    cc "$SPAMDIR"
    `$MARK_READ $SPAMDIR`
    exit
}

I had to have bogofilter learn spam and ham, which I had plenty of in local mailboxes. And apart from configuring mu4e to be able to mark a message, there’s no configuration needed for bogofilter.

Once the incoming email arrives properly to my local inbox, indexing it for the first time with mu is a just single mu index call.

Next, going through the mu4e info enabled me to get a functional setup. What actually took time was to actually fine-tune mu4e to accommodate my tastes, things, like:

  • switching gracefully between different accounts
  • automatically archiving a message to a ~/Mail/account@email.com/Archives/.<CURRENT_YEAR>/ folder
  • copy a message path for filesystem inspection

Something I never managed to do is to bounce or resend a message, when I’m not the correct recipient. While this feature is perfectly legit as described in the original SMTP RFC, it’s in practice rarely implemented in mail clients.

Regarding the email accounts, it’s maybe worth noting that I attempted to host my own email server in the past, for sending and receiving, i.e. SMTP and IMAP. But I never really switched to it for my personal email, as I had not found any failover SMTP server. Before leaving Gmail for good, I thus started using my DNS registrar’s email service.

Conclusion

After an initial couple of weeks tweaking and tuning my mu4e configuration, I have been a very happy user since. I barely touched the rest of the stack (imapfetch, maidrop, bogofilter).

Recently mu-1.8 dropped its own message view to adopt the one from gnus (artice-mode). That’s giving me a bit of a headache as a significant part of messages I receive are not decoded properly. Also it’s not as easy to interact with attachments2.

This is obviously a lot of work and hassle and I don’t expect anyone to follow. Nevertheless it feels good being in control of my email. mu4e has been a joy to use so far. 🏎️


  1. Nowadays I sometimes need to access my email from my phone. I’m not sure how to conciliate security, privacy and convenience. Maybe a distinct email address would do? ↩︎

  2. Although I just learned about <attachement> A o to say open an attachement quickly. ↩︎