Arrange your e-mail with Notmuch

Final 12 months, I introduced you 19 days of latest (to you) productiveness instruments for 2019. This 12 months, I am taking a special strategy: constructing an surroundings that can permit you to be extra productive within the new 12 months, utilizing instruments chances are you’ll or could not already be utilizing.

Index your e-mail with Notmuch

Yesterday, I talked about how I exploit OfflineIMAP to sync my mail to my native machine. As we speak, I will discuss how I preprocess all that mail earlier than I learn it.

Maildir might be some of the helpful mail storage codecs on the market. And there are a LOT of instruments to assist with managing your mail. The one I maintain coming again to is a little bit program known as Notmuch that indexes, tags, and searches mail messages. And there are a number of applications that work with Notmuch to make it even simpler to deal with a considerable amount of mail.

Most Linux distributions embrace Notmuch, and you may as well get it for MacOS. Home windows customers can entry it by means of Home windows Subsystem for Linux (WSL), however it might require some extra tweaks.

On Notmuch’s very first run, it can ask you some questions and create a .notmuch-config file in your house listing. Subsequent, index and tag all of your mail by operating notmuch new. You may confirm it with notmuch search tag:new; this can discover all messages with the “new” tag. That is most likely plenty of mail since Notmuch makes use of the “new” tag to point messages which are new to it, so you may wish to clear that up.

Run notmuch search tag:unread to search out any unread messages; that ought to end in quite a bit much less mail. To take away the “new” tag from messages you have already seen, run notmuch tag -new not tag:unread, which is able to seek for all messages with out the “unread” tag and take away the “new” tag from them. Now while you run notmuch search tag:new, it ought to present solely the unread mail messages.

Tagging messages in bulk might be extra helpful, although, since manually updating tags at each run will be actually tedious. The –batch command-line possibility tells Notmuch to learn a number of strains of instructions and execute them. There may be additionally the –input=filename possibility, which reads instructions from a file and applies them. I’ve a file known as tagmail.notmuch that I exploit so as to add tags to mail that’s “new”; it seems one thing like this:

# Handle despatched, spam, and trash folders
-unread -new folder:Trash
-unread -new folder:Spam
-unread -new folder:Despatched

# Be aware mail despatched particularly to me (excluding bug mail)
+to-me to:kevin at sonney.com and tag:new and never tag:to-me

# And observe all mail despatched from me
+despatched from:kevin at sonney.com and tag:new and never tag:despatched

# Take away the brand new tag from messages
-new tag:new

I can then run notmuch tag –input=tagmail.notmuch to bulk-process my mail messages after operating notmuch new, after which I can search on these tags as nicely.

Notmuch additionally helps operating pre- and post-new hooks. These scripts, saved in Maildir/.notmuch/hooks, outline actions to run earlier than (pre-new) and after (post-new) to index new mail with notmuch new. In yesterday’s article, I talked about utilizing OfflineIMAP to sync mail from my IMAP server. It is very straightforward to run it from the “pre-new” hook:

#!/bin/bash
# Take away the brand new tag from messages which are nonetheless tagged as new
notmuch tag -new tag:new

# Sync mail messages
offlineimap -a LocalSync -u quiet

You may as well use the Python software afew, which interfaces with the Notmuch database, to tag issues like Mailing Record and Spam for you. You may run afew from the post-new hook in the same approach:

#!/bin/bash
# tag with my customized tags
notmuch tag –input=~/tagmail.notmuch

# Run afew to tag new mail
afew -t -n

I like to recommend that when utilizing afew to tag messages, you do NOT use the [ListMailsFilter] since some mail handlers add obscure or downright junk Record-ID headers to mail messages (I am taking a look at you, Google).

At this level, any mail reader that helps Notmuch or Maildir can work with my e-mail. I will generally use

alot

, a Notmuch-specific consumer, to learn mail on the console, however it’s not as fancy as another mail readers.

Within the coming days, I will present you another mail purchasers that can seemingly combine with instruments you already use. Within the meantime, take a look at a few of the different instruments that work with Maildir mailboxes—you may discover a hidden gem I’ve not tried but.

Supply

Germany Devoted Server

Leave a Reply