Categories
Productivity

Taking back email – Part 3: notmuch

Recently, I decided to revamp my email setup. I don’t have too much going on with email, but it’s such an important method of communication that I needed to get it under control. I’m going to put together a several-post guide explaining my reasoning, technical details, and my new email process.

Other posts in this series (all will be linked here as the posts go up:)

Intro

notmuch is an email indexer and tagger. It’s used to create a searchable database of mails and to allow you to arbitrarily tag emails with different keywords. Searching for your email is easy and SUPER fast with notmuch.

I have notmuch installed on my home server along with OfflineIMAP, although using a remote VPS would work just as well. This way, my email folders and database have a central home, and I can sync them to my various workstations with Syncthing.

Installing notmuch

This is easy in Arch Linux:

sudo pacman -S notmuch

Notmuch might be packaged for your Linux distro as well. Check in the repositories – if not, then check the notmuch website.

Configuration

Instead of copying and editing a config file, notmuch bootstraps the configuration. Just run a command:

notmuch setup

And you’ll be dropped into an interactive setup. Simply answer the questions:

  • Your full name (“Aaron Young”)
  • Your primary email address
  • Add any other email addresses you are configuring (this all will mirror your OfflineIMAP config)
  • The path to your mail directory. This is the same folder where OfflineIMAP is downloading your email.
  • Tags to apply to new mail: “unread” and “inbox” are the defaults and they’re just fine, but feel free to add or remove tags to fit your workflow. These tags will be automatically applied by notmuch on new emails that come in.
  • Tags to exclude when searching email – these are the emails that you never really want to see.

Now, you can take a look at the config that was generated:

vim ~/.notmuch-config

and see how you like it.

Running after OfflineIMAP sync

So the basic setup so far has OfflineIMAP checking for new email, once an hour with your cron job, and putting it in your local mail directory. Let’s have notmuch tag those new emails.

Use crontab -e to edit your crontab, and add:

47 5-21 * * * offlineimap && notmuch new

Now, notmuch will process your email after offlineimap has finished downloading it. Of course, this is the same cron command that I mentioned in the last post in this series, but now we understand the second part.

Next Steps

Now, our central server is fetching and indexing your emails, and you may have set up Syncthing or a similar service to sync your mail folder between all your workstations. Next, I’ll discuss how to use alot and khard to read and manage your email messages.

Leave a Reply

Your email address will not be published. Required fields are marked *