en 
Etienne Werly

Etienne Werly

My personal website

Independent mathematics teacher, I teach at the moment at the University of Toulouse and as a private teacher.

Handling EMails

How I decided to handle emails

Motivation

I recently set up a self-hosted server, and use it amongst other things for mail. I also have a handful of other mail addresses (a number I'd like to see go down), and had the habit to have local access to my mails on my computer.

I discovered notmuch, which I used locally on my computer and have rather liked this piece of software, coupled with neomutt's virtual folders to easily access tags. I also liked the vim interface of notmuch, but never really got how to easily switch identities when sending mails, which is a problem for me, as I don't work with a single mail address (at least 2, personal and work).

But I often read and reply to mail on my phone and I find this does not bind very well with notmuch: notmuch makes it superfluous to move mails accross folders, whereas if I try to be tidy on my phone I will need to archive mails.

Having acquired a new computer recently, I decided to revamp the way I handle mail a bit. I'm inspired by David Patterson's article, and plan to use my server together with muchsync. I hope that this will make working with mails more manageable in the future: on my phone I should only recieve "important" mails, which I hope will avoid the need to archive mails. What's more, I will have my tags stored "in the cloud". Well... in a cupboard in my house, but still!

I disregarded using notmuch remotely, as I find important to have offline access to my mails (I hate realizing when you need it quick that you need to connect your computer to the network to access a piece of info you know you read a day ago on this same machine but now you're not at home). Muchsync on the other hand syncs to maildirs along with their notmuch (xapian) database. It means more space on memory, but it also acts as a kind of backup.

Local emails

As I Already have a mail server installed and running on my server, I would be disapointed to have two copies of each mail on the server, one copy for Dovecot, and one for me.

I have hence granted access to my mail folder on the server to my user profile (which is a risk I'm pretty sure I don't grasp the extent of), and symlinked it to a folder in my home directory. Notmuch will be able to read those, and should not interact with Dovecot in an undesirable way.

Fetching emails

For other mail addresses, I will have to fetch mail on other IMAP servers, which is done with offlineimap, as it supports IMAP IDLE. Turning IDLE on does not show very clearly in the doc -- I find. So here's a sample of what I do to have my Inbox on idle:

[general]
accounts = idleOn

[Account idleOn]
localrepository = idleOnLocal
remoterepository = idleOnRemote
# autorefresh must be set so that offlineimap keeps running when first executed.
# I set the refresh value to 30min as the keepalive is set at 29min by default.
autorefresh = 30
quick = 4

[Repository idleOnLocal]
type = Maildir
localfolders = ~/Mails

[Repository idleOnRemote]
type = IMAP
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
remotehost = idle.on
remoteuser = givemeidle
idlefolders = ['INBOX']

And add the following line to your crontab

@reboot offlineimap -a idleOn

(it is recommended to execute offlineImap as a separate service for each account).

notmuch and muchsync

Once new mail is fetched, it is filtered and tagged along the way, so that it gets classified, and only mail that is worthy of my attention goes through to me. The initial tagging is a script linked to $notmuch_dir/hooks/post-new and is run every time notmuch imports new messages to the database. The basic idea is that every new mail gets the new tag, and a sequence of filters is applied to new messages to sort them in various categories: spam, from-me, invoice,... Those are the mails I do not need to see, but I want to keep. As the sequence of filters ends, every mail that still has the new tag is marked worthy (and unmarked new).

Conveying important mail on phone

On the server, a simple rule is set to move "important" tagged emails to an "Important" folder, for which my phone has push notifications.

For other addresses however, there is a bit more of a back and forth, as mail arrives on my server, is filtered via notmuch and moved to an "Important" folder. After which, there is a new sync with the remote server, to push the changes and "important" tagged mails, moved to the corresponding folder, can be pushed toward my phone.

Muchsync on Android?