User Contributed Notes 21 notes

Since this library at a whole is fairly poorly documented, and it doesn't help that there's 30-something functions, and many of the functions do the same things, I have gone through and categorized the functions. Hopefully this will help somebody else, I know it will help me!! -Justin

If you are having difficulty compiling on netbsd from source and want imap support then you should know that the c-client library is compiled with kerberos support. Unfortunately gssapi_krb5 and k5crypto is not on the system (or at least wasn't for me). I didn't have administrative level access to add these libraries so I had to do the following. I still have to test that it worked 100% but at least it compiled without complaining.

This is verified working via an imap test. One excellent test that I located on the phpbuilder.com site. Here it is. Modify the address, port, protocol type, username, and password appropriately. The post was 5 years old but the script still works fine. The posters name was "Matthew"

Additional notes: a- I choose "lrh" in the make but you might check what's yours option.b- I made it with ssl support and because of this I added the --with-imap-ssl in the php configure option. You might make it with no SSL

Building Apache2, PHP and IMAP requires a shareable versionof the c-client library, but the standard UW code doesn't provide one.I couldn't find any way to build with the libc-client.a without generating piles of relocation errors. (gcc on Solaris 10)

The IMAP c-client library can be built shareable with the following steps:1. fix the Makefile in .../imap-2004/c-client to include:BASECFLAGS="-fPIC -O3"2. make 3. mkdir tmp4. cd tmp5. ar xv ../c-client.a (to extract the .o files)6. gcc -shared -o c-client.so *.o (to create the .so library)7. copy that c-client.so to /usr/local/imap/lib/libc-client.so (it may be necessary to hide the libc-client.a)8. configure PHP ; make; make install

The c-client.a isn't present on your system after you've installed the imap-uw package. !But! it's actually present at a specific time during the install phase as it's being complied from source - it's just deleted at the end of the compilation process. So, we'll have to break the install process down into it's component processes and get hold of what we need at the appropriate time:

If you like me disvoer that "make slx" fails, but you're damn sure you've openssl installed then, it might be that the lib and include paths on your distro are different then the defaults provided in the imap-2004a (or imap-XXXXx). To modify go to dir ../imap-2004a/src/osdep/unix and edit the section (shown below) in the Makefile

3. Compile PHP with SSL support, --with-imap=/path/to/imap/source/ . If SSL support fails, you'll get a configure-time error that IMAP doesn't work. This is a lie, you just need to get SSL support working in PHP. On certain linux systems, with OpenSSL 0.9.7, this means adding --with-openssl=/usr (if the OpenSSL files are in /usr/include/openssl/) instead of the proper directory containing the OpenSSL files. For some reason, giving a parent directory makes PHP able to find the OpenSSL include files.

4. PHP should build.

Alternately, you can disable SSL during the IMAP build, as per the previous directions posted here.

I had a lot of trouble with all the advice here, but I finally got it working, so I thought I'd leave my steps. If you know a decent amount about UNIX you can probably do better on you own.#1) downloaded version listed by php.net above.#2) ran "make opx" on it (the three-letter is your OS, opx is later osx versions)#3) copied resulting c-client/ folder to where I wanted to leave my imap stuff, herafter referred to as IMAP_HOME.#4) renamed IMAP_HOME/c-client/c-client.a to libc-client.a#5) ran "configure" on php using --with-imap=IMAP_HOME --with-kerberos --with-imap-ssl (my configure insisted that I use the last two)#6) make, make install, and restarted Apache. Voila!

At this point you can delete the downloaded imap stuff, or move it to your sources/ folder or whatever.

However. In order for me to get SquirrelMail woorking, I had to install ports/mail/imap-uw with WITHOUT_SSL=yes and same option for ports/mail/cclient. After doing this, I recompiled cclient w/o any options to get SSL support, and then installed posrt/mail/php5-imap.

This works. But if you just want SSL everywhere - install imap-uw normally, which will install cclient too. After that, install php5-imap normally as well - and you have a working system with SSL.

Hope this saves more people from wasting too much time like I just did ;)

The IMAP php plugin doesn't work by default with Microsoft Exchange 2007 server, so I had to recompile php with the c-client without Kerberos support.

Also, I wanted to compile it as a shared library (imap.so).

The quick and easy way that I've used to do this on Fedora Core 13 & 14 x64 was:1) Create a temporary folder and cd to it.2) Download c-client.tar.Z from ftp://ftp.cac.washington.edu/imap/3) Extract the c-client.tar.Z file, using 'tar -zxf c-client.tar.Z', which would create the imap-2007e folder at this moment.4) Download php source code using 'yumdownloader --source php' *(a)Extract the php-*.rpm file to get the php-*.tar.bz2 source package *(b)5) Install php-imap plugin using 'sudo yum install php-imap', or you can simply just add the php ini file for the imap.so extension6) Go to the imap-2007e folder and edit the Makefile such that the 'EXTRACFLAGS=' line reads: 'EXTRACFLAGS=-fPIC'7) Compile c-client. I had to use 'make lfd IP6=4'8) Go to the php source folder and run the configure script with the following arguments: './configure --with-imap=shared,<path to imap-2007e folder> --with-imap-ssl'eg. I used './configure --with-imap=shared,/home/chris/imap-2007e --with-imap-ssl'9) Compile php by simply running 'make' *(c)10) Copy/replace the imap.so file from the ./modules folder to your PC's php module folder. I used 'sudo cp ./modules/imap.so /usr/lib64/php/modules'11) Restart Apache: 'sudo service httpd restart'12) Check imap section of <?php phpinfo(); ?>, and it should only list IMAP c-Client Version and SSL Support. The Kerberos Support should NOT be listed here!

There are slight differences in achieving the same in Ubuntu 10.04 x64 (or perhaps other versions too):4) Download php source code using 'apt-get source php5', which will create a php5-* source folder5) Install the php5-imap plugin using 'sudo apt-get install php5-imap'7) Compile c-client. I had to use 'make ldb IP6=4'10) Copy/replace the imap.so file from the ./modules folder to your PC's php folder. I used 'sudo cp ./modules/imap.so /usr/lib64/php5/20090626'11) Restart Apache: 'sudo service apache2 restart'

* Notes:(a) yumdownloader is part of yum-utils package, which can be installed using 'yum install yum-utils'(b) You can extract the rpm file using 'rpm2cpio php-*.src.rpm | cpio -idmv'(c) You can greatly improve the compilation speed on a multi-core PC using 'make -j `grep -c ^processor /proc/cpuinfo`'