Config.lua – personalised.

Organising emails has been a really hard task. (scroll down for the code)

After I quit gmail (about a year ago), I have been using mail clients (mostly Thunderbird) with IMAP configured. With multiple machines in various locations, email organisation was becoming unpleasant. All I had to do was keeping the Thunderbird synchronized everywhere, and I was/am lazy. (Aslo, what if I was to use Windows mail, or Outlook?)

I hadn’t heard about imapfilter a couple of weeks ago.  So, I installed it on my Ubuntu and configured it real nice :)

If you don’t want to read the explanation, but wand to just see the code, find the skeleton of my config.lua at github.

After looking at a couple of pages, I realized that if I needed to get something working, I have to make it.

I took he idea of filters from here. But that wasn’t enough for me, as my most treasures were personal emails. So, I wrote the following three functions.

1. Find all the emails written from a person. Any person of today has more than a few ids. So, all his/her emails ids are in a table, and all the emails sent from any of those ids in the specific FOLDER will be in the result.

2. Now, all the emails which were sent to a person. I kept “to”, “cc” and “bcc” in three separate lines so that they could be commented out easily.

3. Now, all I needed was a function to find all the emails between me and any given specific person. (All mails between Alice and Bob)

4. Finally, I had to make a table of all my contacts and then use the above functions to move the emails around. I listed the ids of my friends/family, and then put them in a small table, and the functions were taking care of the moving of emails.

And call it by: (As a restriction, I applied the filters only to emails which are at least a week old, or already answered by me. )

But as you can see, the function (aptly named doAllMovingExpensive) is an expensive function as it always has to compute the emails from and to me — because it has to be done for each and every other person/group. So, I wrote another function which saved a lot indeed.

5. Pre compute all the emails to/from me, and then use the filter on the result and update the result as emails are filtered out of it.

And call it by:

6. And finally I have the following script for running imapfilter to organise the emails, and also offlineimap to pull them home.

Also, I added it to contrab, with crontab -e.

And I haven’t had to bother about organising the emails, ever since! :) Yaay!

Signing off,
Sands.

PS: I need to do proof reading, but that doesn’t have to stop you from nitpicking and being pedantic. :)