Remote notmuch via imap and ssh

I store my email on a small, low power, computer at home and browse it via imap from my devices (laptop, pandora) using mutt. I'm also using notmuch, running on the same computer, to index and search email. Of course, I want to access both searches and the tagging facilities from my mail client, remotely.

Part of the work has already been done: Stefano Zacchiroli wrote an helper tool and a guide on How to use Notmuch with Mutt, and the notmuch wiki includes informations on using notmuch remotely, which could significantly improve my solution.

Configuration

Dovecot

I need a place outside the main email directory, but served via imap by dovecot; in /etc/dovecot/dovecot.conf I've added the following snippets:

namespace private {
   prefix =
   inbox = yes
}

namespace private {
   prefix = "Notmuch/"
   inbox = no
   location = maildir:~/.notmuch:LAYOUT=fs
}

Mutt

Mutt configuration includes commands for a few common tasks. Note that I'm still using the old unpackaged version of mutt-notmuch; as soon as I update to wheezy (or the notmuch-mutt package enters squeeze-backports) I will update them.

First of all plain search, almost straight from Zacchiroli's manpage:

macro index <F7> \
      "<enter-command>unset wait_key<enter><shell-escape>ssh mail.example.org \'mutt-notmuch -o ~/.notmuch/search --prompt search\'<enter><change-folder-readonly>imaps://mail.example.org/Notmuch/search<enter><enter-command>set wait_key<enter>" \
      "search mail (using notmuch)"

As well as thread recontruction:

macro index <F8> \
      "<enter-command>unset wait_key<enter><pipe-message>ssh mail.example.org \'mutt-notmuch thread -o ~/.notmuch/search\'<enter><change-folder-readonly>imaps://mail.example.org/Notmuch/search<enter><enter-command>set wait_key<enter>" \
      "search and reconstruct owning thread (using notmuch)"

Then a few commands to tag emails that need further attention: long messages that I should read carefully and things that requires an answer:

macro pager <esc>tr \
      "<enter-command>unset wait_key<enter><pipe-entry>ssh mail.example.org \'~/bin/notmuch-tag-email.sh +todo::read\'<enter><enter-command>set wait_key<enter>"\
      "notmuch tag +todo::read"

macro pager <esc>tR \
      "<enter-command>unset wait_key<enter><pipe-entry>ssh mail.example.org \'~/bin/notmuch-tag-email.sh -todo::read\'<enter><enter-command>set wait_key<enter>"\
      "notmuch tag -todo::read"

macro index <esc>Tr \
      "<enter-command>unset wait_key<enter><shell-escape>ssh mail.example.org \'mutt-notmuch -o ~/.notmuch/todo/read search tag:todo::read\'<enter><change-folder>imaps://mail.example.org/Notmuch/todo/read<enter>" \
       "search messages taged todo::read"

macro pager <esc>ta \
      "<enter-command>unset wait_key<enter><pipe-entry>ssh mail.example.org \'~/bin/notmuch-tag-email.sh +todo::answer\'<enter><enter-command>set wait_key<enter>"\
      "notmuch tag +todo::answer"

macro pager <esc>tA \
      "<enter-command>unset wait_key<enter><pipe-entry>ssh mail.example.org \'~/bin/notmuch-tag-email.sh -todo::answer\'<enter><enter-command>set wait_key<enter>"\
      "notmuch tag -todo::answer"

macro index <esc>Ta \
      "<enter-command>unset wait_key<enter><shell-escape>ssh mail.example.org \'mutt-notmuch -o ~/.notmuch/todo/read search tag:todo::answer\'<enter><change-folder>imaps://mail.example.org/Notmuch/todo/answer<enter>" \
       "search messages taged todo::answer"

These use a small script, ~/bin/notmuch-tag-email.sh:

#!/bin/sh

ID=$(awk '/^Message-[Ii][Dd]:/ {gsub("<",""); gsub(">","");  print "id:"$2}')

notmuch tag $* $ID

I'm wondering if I should add a generic tagging command, but right now I have no other tag planned, so I'm waiting to see if I have a real need for it.

Send a comment: unless requested otherwise I may add it, or some extract, to this page.

Return to Top