About Archive Tags RSS Feed


Scriptable email clients

5 September 2011 21:50

This is just a quick post to remind myself in the morning, as soon as I've made it I intend to turn my computer off and leave it off until I can re-organize my office.

I've been using mutt for my email for the past few years. Nothing compares to the flexibility of procmail/sieve for organizing server-side mail, and then mutt is ideal for reading them.

With the addition of the mutt-patched sidebar mode you can even go for a few days before realizing you're not in a graphical environment. But one thing I do long for is the ability to execute scripts at various times.

Thus far I've not actually planned what I'd like to do, but as a starting point imagine being able to execute a hook when new mail arrives? Or when you send a message matching a pattern in some fashion?

There are some things out there, such as the various hacks which are designed to abort sending a message if you mention "See attachment" in a message body but fail to add one before sendign the message. These hacks generally abuse the sendmail configuration such that they're extremely ad-hoc and hard to chain/nest.

I've mellowed out over the years and I have no interest in attempting to write a mail-client (though at the same time how hard can it be? Just restrict yourself to using inotify on ~/Maildir and offload delivery to exim and you're almost done? I guess the hard part is the UI, though I do like the mutt + sidebar layout. Write the whole thing in some scripty language?)

I'll re-examine notmuch and gnus over the next week or two, but I suspect both will continue to disappoint in various ways.

Anyway, for the moment I'm just pondering. But threading is an obvious concern. Most current mutt hooks relate to the local folder, or the local message. If I were viewing a message in one directory and a new mail notification fired for a delivery to both ~/Maildir and ~/Maildir/.people.foo I'd need to either serialise them or thread them.

Ponder ponder.

In other news I've been doing more photography recently. Nothing cohesive except for my recent experiment with shooting a "street-girl" outdoors in falling light, but that was an interesting challenge and the results were sufficient to make me want to try shooting outdoors in an organized fashion again. (Some random images have been linked to from my wee twitter page.)

ObFilm: "She doesn't get eaten by the eels at this time " - The Princess Bride



Comments on this entry

icon Adam at 19:26 on 5 September 2011

How hard can it be - I guess that is one of the reasons that there are so many half-finished email-clients?

Character sets, MIME encoding of headers, MIME encoding of content, folding headers, parsing dates, handling References, Reply-To, mailinglists, threading, searching, filtering, cleaning up broken emails (Microsoft Outlook chars, misfolded quotations, ...), encryption, signing, smileys, bold/italic/underline, X-Face/Face/Gravatars, flags, etc. etc. etc.


icon Michael at 19:31 on 5 September 2011

I switched to sup (http://sup.rubyforge.org/) a while ago. It's written in Ruby, provides hooks of all kinds and a thread-centric gmail-like UI. Certainly worth a look. I switched from mutt and never looked back :).

icon dim at 20:33 on 5 September 2011

I also think writing a MUA is a huge job. Particulary a good one, and you already know about that because out of the millions out there you're complaining about mutt.

I use gnus and I wouldn't use anything else. Get to learn some ELisp if you're not yet at ease with it, then you have the keys to the kingdom, really. Amazing what your workflow looks like when you have all the control over it, without ever needing to go convince upstream about your vision...

icon Steve Kemp at 04:07 on 6 September 2011

I knew I'd forgotten about one, sup, thanks for reminding me.

I tried importing a subset of my mail into a fresh installation of sup:

sup-add --labels=247blinds,co,uk maildir:///home/skx/Maildir/.247blinds.co.uk/
sup-add --labels=alioth maildir:///home/skx/Maildir/.alioth/
sup-add --labels=Amazon,co,uk maildir:///home/skx/Maildir/.amazon.co.uk/
sup-add --labels=Automated,bounces maildir:///home/skx/Maildir/.Automated.bounces/
sup-add --labels=Automated,cron maildir:///home/skx/Maildir/.Automated.cron/
sup-sync -v

This crashed almost immediately, which is what I remember from when I tried to use it last time.

Adding new message maildir:///home/skx/Maildir/.amazon.co.uk/#10638972990005255 with labels Amazon,uk,inbox,co
/usr/lib/ruby/1.8/rmail/header.rb:537:in `content_type': undefined method `downcase' for nil:NilClass (NoMethodError)
	from /usr/lib/ruby/1.8/sup/message.rb:444:in `message_to_chunks'
	from /usr/lib/ruby/1.8/sup/message.rb:244:in `load_from_source!'
icon Charles Stewart at 09:03 on 6 September 2011

You can use both Procmail and Mutt with MH-style directories, allowing you to use nmh for scripting. MH syntax is a bit clunky at the shell prompt, but it's great for writing scripts. Mutt has similar caching tricks for MH as it has for Maildir.


Christian Neukirchen recently wrote MH-style scripting support for Maildir folders. It looks nice, but I haven't tried it yet.