hotswapping by rndmcnlly licensed cc-by


Program or be programmed quote by Douglas Rushkoff

hotswapping by rndmcnlly licensed cc-by

I’ve just finished Program or be Programmed by Douglas Rushkoff. It’s a relatively short read (approx 150 pages) and tries to explain the need for understanding technology and creating (with) technology instead of just using it. I’m a advocate for programming literacy striving towards making people aware of the influence of technology on our society, so I just had to read what Rushkoff has to say about this.

At first I was not so impressed. The first chapters mostly felt like filler content. Actually I can’t even remember the main arguments brought forward in those chapters. However the last chapter really made up for this lack of content in the first chapters. I think the quote below sums this up nicely:

“For the person who understands code, the whole world reveals itself as a series of decisions made by planners and designers for how the rest of us should live. Not just computers, but everything from the way streets are organized in a town to the way election rules (are tilted for a purpose vote for any three candidates) begin to look like what they are: sets of rules developed to promote certain outcomes. Once the biases become apparent, anything becomes possible. The world and its many arbitrary systems can be hacked.”

Source: Program or be programmed

— ♦ —

The recommended alternative for procmail server based mail filtering is maildirproc

If you’re like me, you probably receive a lot of email everyday. Some of it needs our immediate attention, but most of it can be dealt with at some time in the future. In order to filter these emails into the correct categories I’d use Procmail, which is a server based mail delivery and filtering agent (MDA). You might wonder why I prefer filtering on the server?

Filtering on the server allows me to easily switch between mail clients like Mutt, Thunderbird and webmail without having to wonder about each client’s specific filtering options. The server deals with the filtering and serves my mail via IMAPS to whatever client I might use to read my mail. Procmail served me well, but it’s arcane ‘language’ to construct rules by which emails are sorted into different folders is a pain to use.

It became harder and harder for me to create correct rules to filter my mail. This resulted into less important mail cluttering up my inbox hiding the important mail and even important mail being sorted into the wrong folder. So I set out to find an alternative for Procmail.

Surprisingly it took way longer than I anticipated to find an alternative to Procmail. Apparently most people just deal with Procmail’s arcane mumbo jumbo language. After some failed attempts I stumbled upon maildirproc by Joel Rosdahl. As Joel puts it:

maildirproc is a program that processes one or several existing mail boxes in the maildir format. It is primarily focused on mail sorting — i.e., moving, copying, forwarding and deleting mail according to a set of rules. It can be seen as an alternative to procmail, but instead of being a delivery agent (which wants to be part of the delivery chain), maildirproc only processes already delivered mail. And that’s a feature, not a bug.

The greatest feature of maildirproc is not even mentioned in this quote: it uses the regular Python programming language to construct rules by which your mail will be sorted. Python is widely regarded as a great readable programming language which suits both aspiring as well as advanced developers. By using Python it is quite easy to construct rules to filter emails. The documentation and examples of maildirproc should have you up and running within minutes.

Personally I still use Procmail as MDA, but it only makes sure my emails will be put into the inbox. Maildirproc will take care of the sorting. I run maildirproc using cron, so that I can see every mail coming in, but all the less important stuff will get automatically sorted every minute or so.

I highly recommend using maildirproc to sort your email instead of Procmail!

— ♦ —

Test mail during PHP development without a mailserver

During development I usually don’t want to send out email to recipients. I just want to make sure it will get sent, but I don’t care about it reaching it’s destiny (yet). Basically testing that my code does indeed send out mails when I ask it to do so :)
After searching for some time I’ve found a brilliant little one-liner written by Sean Coates some time ago. It’s a quick and dirty hack, but it works brilliantly for my purposes.

I’ve elaborated a bit more on Sean’s piece mainly on the installation, so even if you’re not that experienced you should be able to follow along. Also read Sean’s article as it contains a more sophisticated solution as well!


Preamble

I use Linux on my development machines, but I suppose it should work with any Unixish type of OS, such as OS X or *BSD. Probably doesn’t work on Windows (leave a comment for a Windows based solution).

  1. Ok, first put the following line in a file called ‘logmail’ (without the quotes!):
    cat >> /tmp/test-emails-sent.log
  2. Save the file somewhere you can find it back ;) In my case, like Sean, I’ve used /usr/local/bin as the directory for this file.
  3. Then make sure it has execute rights. You may set it by typing in: chmod +x /usr/local/bin/logmail
  4. Finally if you use PHP you need to change the sendmail_path variable in your php.ini. In my case (I’m using Ubuntu 11.04 and 11.10) I’ve added a file called mail.ini to the /etc/php5/conf.d directory with the following line:
    sendmail_path=/usr/local/bin/logmail
  5. Restart Apache by typing sudo service apache2 restart
  6. Test your application’s mail sending capabilities by looking at the test-emails-sent.log in your /tmp directory
— ♦ —