Friday, August 10, 2012

IMAP module for PHP in Mac OS X Mountain Lion

So here it comes again. I have recently upgraded to Mountain Lion and for whatever reason, Apple decided to nuked all my previous PHP (among other things) configurations so I have to setup IMAP in PHP again. A simple Google search may point you to this post with detailed instruction for Lion however, some steps have been changed a bit...

Step 1: Install prerequisites

You may choose to download Xcode (FREE) from the App Store then go to menu Xcode > menu item Preferences > tab Downloads, select to install Command Line Tools OR you can go to Apple Developer to get it, you may need to login.

Step 2: Compile IMAP

Get the IMAP source code from University of Washington website. Please do me a favor and check that website for the latest version, it's good practice. If you that lazy, try to click the "y" to get direct link to 2007f version.

Extract the package and open the Terminal to the new directory before executing these command:

  1. make osx EXTRACFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
  2. sudo mkdir /usr/local/include/
  3. sudo cp c-client/*.h /usr/local/include/
  4. sudo mkdir /usr/local/lib/
  5. sudo cp c-client/*.c /usr/local/lib
  6. sudo cp c-client/c-client.a /usr/local/lib/libc-client.a

(1) may take a while because the machine need to compile quite a few files for IMAP. Warnings are okie (I got 3 warnings) but if you see some error, that's not good. Please use some Google-fu to figure it out before continuing.
(2) and (4) may tell you the directory has already exists, that's okie and expected.

Step 3: Compile IMAP module for PHP

Following the instruction from PHP: Git Access page to get the source code of PHP. Please note that you should get the same version as the installed PHP engine. By default, Mountain Lion uses PHP 5.3.13 (check this by executing "php -v" in your Terminal).

Basically, you will need to execute 2 commands:
  1. git clone php-src
  2. cd php-src
  3. git checkout PHP-5.3.13
(1) may take a long time depending on your internet connection because the repo is huge.
(2) will check out the branch for a specific PHP version, because my machine uses PHP 5.3.13, I choose the branch "PHP-5.3.13", switch it to match your system.

In order to compile the IMAP module, execute these commands:
  1. cd ext/imap/
  2. phpize
  3. ./configure --with-imap=/usr/local/imap-2007 --with-kerberos --with-imap-ssl
  4. make
  5. sudo cp modules/ /usr/lib/php/extensions/no-debug-non-zts-20090626/
I don't know why Daniel (the author of the original instruction post) got problem compiling IMAP module for PHP (he said PCRE is missing). Probably the PHP shipped with Mountain Lion got PCRE already so the above 5 commands is all I need. Ivan pointed out that Mountain Lion is not shipped with PCRE so you will need to install it yourself.

Now you only need to modify the php.ini file to include the new module. Use your favourite editor to open the file /etc/php.ini (sudo is required to save it FYI), and add this at the end of the file:

; added IMAP module at

Step 4: Enjoy

You are now good to go. Restart Apache as necessary using this: "sudo apachectl graceful".

That's it. Good luck!

Happy I got some follower!


The little things that matter!
More sites should do this. But they should have some limit in place because users will not want to receive this kind of mail every day. Once a month is too much already. For the record, this is the first one I got from Tumblr -- that's why I'm so excited!

Wednesday, August 8, 2012

It has been such a long time but today, August 8th, 2012, I have just found out that a homepage which was designed by me years ago (circa 2007?) is still up and running here

It is the homepage for UpdateSofts forums. A kinda underground one where I used to come to get warez in the early days. It was the largest one in Vietnam for quite a long time (in warez, probably the second largest one in general being below DDTH). But no more now I think, people are now a little bit better when it comes to software piracy, they will try to buy it when it's possible especially when many international software companies have resellers in Vietnam (namely Kaspersky, Microsoft, etc.) with a good pricing for the market. I remember the time when software and game store popped up everywhere. It's so easy for highschool boys to visit one of them on the way home, spent a few minutes reading the "NEW GAME" list and paid eight thousand VND (an equivalent of $0.5 at the time) to buy the game CD. So easy! Getting the operating system or utilities is basically the same, just get to the store, pick up some CDes: one for the Microsoft Windows XP SP3 Professional, one for Microsoft Office 2003 Professional, etc. (I feel bad for Microsoft now hehe). When internet access became better, people only need the OS disc, the rest can be downloaded from sites like UpdateSofts. Good days! I was the 338th member of the site. I think I joined the same month it lauched. Mostly because one of the site founder is my all time favourite people (ngocha85, please do not think it's a girl, he chose his wife's name as his username across almost every site I know).

Back to the homepage, looking back to the source code I'm glad I put a few credits to myself back then.

This is the second line in the source code

Not sure why it's here though. Probably because I put the HTML page up in my website so Mr. QAD can get it easily. Back in that days, I was "feelXtheXlife" in "The Life Corp" with my buddies in highschool. Good a picture that I took a long time ago here too, haha:

And this is taken from the metadata section of the HTML page:

content=Pon name=author>
content="© Pon" name=copyright>

Not bad I would say. I knew enough back then to use quotes with string like "© Pon" but skip them when it's possible. Quite smart eh!? But as I looked further into the mark up, it's clear that I used something like Microsoft Frontpage to create the page (all the tags are in UPPERCASE, perfect-but-inconsistent usage of quotes, generator as "MSHTML 6.00.5700.6" in the metatag). But it's still quite good of myself I think.

Talking about the CSS, I made the page not long after learning about a technique that create smooth border without images (back in that time, border-radius haven't existed yet, people have to use images to create them). The trick was using 3 level of containers and make them a few pixels smaller than each other so we have a quote-smooth border effect. In the HTML page, the main CSS selector is ".kutebox", so cute!

I have put the entire HTML page up here just in case the site decides to remove it in the future. I certainly do not hope so!