« Back to Nicolas Pouillard's Blog

Date: Saturday 03 Oct, 2009, Tags: email, gtd, sup, unix

Simple E-Mail Delaying

Yesterday I have finally scratch an itch that was bugging me since months. And guess what it fits in less than 40 lines of shell script!

E-Mail Driven Actions

I tend to be quite bad at managing tasks to do, however I try improve myself, and already follow two simple rules. The first one is called the "two minutes rule," it says that if one thing you have to do takes less than two minutes, then it does not worth to be delayed, you should do it now! The second rule I apply is to do tasks when it pops-up in my email client (sup).

However from time to time, I receive an email which incurs a "more than two minutes" action, that I cannot cope with now. If I keep that email in my in-box, it will keep bugging me until I either pick it up or trash it because it is now outdated.


The feature I often wanted is to be able to delay an email-based action, without having to pick it up myself in the pool of waiting emails. More precisely I really enjoy the event based approach of email processing, it is just that some emails come at the wrong time.

In this kind of situation I would like to say, "bring me that email again in two days" or "this evening" or "2 days before " or "when in vacations" or "when back online"... This way you can keep both your in-box clean (in-box-zero) and continue to follow an event based style of reacting.

This technique can also be useful to passively distribute the answer to a question among a group on a mailing-list. If you feel not the most concerned about the question then you can say "let's wait two days," and answer something if no one took it before!

Getting Delaying Into Sup

The next point was to actually have the feature in the email client I use. However I didn't really take the time to implement this. It seemed quite easy but a bit tedious and with a bunch of design choice: Where to store reminders, how often do we check them, do we poll, do we use threads, timers...

BAM! Unix Philosophy To The Rescue

During months, instead of actually coding this not-too-complex module, I was procrastinating. However this was not vain, since I got a better idea. What if we could make this feature independent of the email client? Even better I could reuse and compose existing tools!

So, the usage is as follow: you are on a discussion, and you want to delay processing it. In sup you press '|' to pipe the current email to a given program. I have named that command email-reminder. It reads the email, extracts the Message-ID and setups a task at the given time specification. The task is simply to reply to the email using the Message-ID. The time specification is the one defined by the at(1) Unix command.

About the script

The script first extracts the Message-ID (and the Subject) of the input mail. Then it cooks up a little response email, using your email and the current date, generating a Message-ID and the In-Reply-To field. Finally it runs the at(1) command, feeding it with the time specification and a call to the $SENDMAIL or msmtp(1) command.

This little script is now published on github.