Monday, October 7, 2013

The command-line vs. my work e-mails

I think most of us can relate to the frustration you can feel when your inbox at work gets flooded. Obviously, some e-mails are important, while others are little more than a nuisance. Then there are a bunch of e-mails that are somewhat interesting, but you want to save them for later reading. One solution to this mess is to create folders for your e-mails, on the server. Then you can sort them into categories and put them in folders, allowing you to deal with more urgent stuff first. If you have to do this manually, it kind of defeats the whole purpose, so you'll want an automatic filter that does it for you, in accordance with rules that are tailored to your specific needs. Any decent e-mail client should support that (while I noticed that Apple Mail tends to be very buggy when it comes to filtering, Mozilla Thunderbird works just fine).

So far so good, but then you might find yourself in my situation. I use three different computers, one Android phone and one Android tablet to access my e-mails. Setting up and maintaining all the filters I need on these five platforms is a daunting task. Consequently, I want all my filters to be run on the server instead of on these five machines. When I access my e-mails, they're already filtered and ready, making everything so much easier.

Now, I could create server-side rules using the webmail interface my employer provides. But I won't. Because, as I have already stated in a previous post, I consider form to be more important that function. And there's no form like the command-line. So, I decided to use my Linux server (it runs on an old decrepit laptop at the moment) to handle the task for me. After some quick googling, I found the very nice "imapfilter" program, which I installed on my server. Being a command-line application, it reads the settings and filter rules from a configuration file, which you edit manually. I skimmed through a few sample configuration files that I also found by googling, and it didn't take more than a few minutes to create a set of rules that covers my current needs.

This may look complicated, but all you have to do is copy a template from someone and then adapt it to your needs. It's really not hard at all, stuff like mark_seen or move_messages are pretty self-explanatory. I had no idea how this syntax worked before, I just looked at the samples and copied relevant parts of them. Most of my rules simply move e-mails to the appropriate folder. Then there's one rule that marks unimportant e-mails as read, and then moves them to the trash folder. By the way, this is not my actual configuration file, as you may have figured out.

When I run it from the command-line in verbose mode (i.e., I instruct it to tell me what it's doing by simply adding "-v" to the command), it spews out a lovely amount of capital-lettered computer-speak. As much as I love watching that, it has to run automatically without my input, so I used the very handy application "crontab" that comes pre-installed on pretty much every Linux and Unix system I've ever tried. Now it runs automatically every ten minutes (I can set the interval to be exactly what I want, but ten minutes works for now) and when I check my e-mails on my phone or any of my computers, everything is already sorted into the appropriate folders or deleted. Wonderful, and very stylish.

The sheer amount of feedback from this application is wonderful, and the capital letters gives a most appealing old-school vibe. The numbers added to each line is a big plus, making it look even more like something out of a 1980s movie. [some lines have been partially censored for reasons related to privacy and paranoia]

No comments:

Post a Comment