Php.cig with IMAP support

I’m trying to build my own php.cgi which supports the imap functions. If you have already built one, and would be willing to let others grab a copy, please let me know.


Well, I succeeded in building my own. Great sence of satisfaction. I don’t know how many of the other modules work, as I’m only using this in one section of my site. None the less, when I have time, I’ll investigate further and build one that I can use for everything. At this stage though, I’m just chuffed that I got IMAP to work :slight_smile:


How did you manage that? I tried doing my own install of PHP5 but couldn’t get IMAP to install. I got confused having to install xxx first and then yyy second, I couldn’t get the first one to install ;_;

You first need to download and compile the imap extension. I got my instructions from

Once I’d done that, I followed the instructions from, adding --with-imap=/path/to/imap/source/ to the php configure statement.

If you’re on jabber, send me your ID, and I’m happy to walk you through it when we’re both online. On the other hand, I’m happy to make a copy of my php.cgi available for download.

I should point out that I’m no expert at compiling software under *nix, just learning as I go.


How did you compile it may I ask? I tried to using Cygwin (for windows) but it didn’t work. I don’t have access to machine with Unix on it.
Could you link to the compiled libraries/files needed? I’m sure that we should be able to use the same files on DH servers?

I don’t have Jabber, but I have MSN.

I used shell access to my dreamhost account (I hope that’s ok), so compiled it on the server that’s running the CGI, which I guess is the ideal situation.

As far as setting up a link, that’s possible I guess. I’ll check with the admin’s if that’s ok, otherwise we could simply put a copy into your home directory.

Use this as a guide, I just went through my history file and grabbed the commands that looked usefull :-S

#get and install the imap libraries
mkdir /home/yourhome/src
cd /home/yourhome/src
tar -zxf imap-2004e.tar.Z
cd imap-2004e
make slx SSLTYPE=none
mkdir lib
mkdir include
cd c-client
cp *.h …/include/
cp *.c …/lib/
cp c-client.a …/lib/libc-client.a

#get the latest version of PHP and install
mkdir /home/yourhome/php
cd /home/yourhome/src

gunzip php-5.0.4.tar.gz
tar -xf php-5.0.4.tar
cd php-5.0.4/

#add any extras you want compiled into the CGI.
./configure \ --prefix=/home/yourhome/php
–with-imap=/home/yourhome/src/imap-2004e \


I’ve put the process I used to get IMAP working up at…

Hope it helps someone.

I got mine to work by using DH wiki and the script provided by rhinosw. Thanks for the help.

For those who can’t connect, you should use

<?php $host = "{}"; //This is the name that appears in bold on the Mail->Addresses part of the DH panel. (It could be a lot of random numbers/letters $user = "user_name"; //Password for the account $pass = "password"; Btw Lance, why don't you use $HOME, and $DOMAIN (in the DH wiki) instead of /home/domain ? Makes it much more portable, especially if you recommend the script to others. $mbox = imap_open($host, $user, $pass); ?>

Thanks decswxaqz,

I’ve updated the page to use $HOME