Snow Leopard PHP and IMAP Support

By Xeon Xai  

Seeing as how the stock Apple Mac OS X 10.6 Snow Leopard PHP 5.3 doesn’t come with IMAP extension support, I realized it was time to add it in to build a tool to extract data from my gmail account emails. Here is the steps I took to get it installed and working.

Step 1:

Download IMAP source code. (2007e as of writing this). Without this, trying to compile the IMAP PHP extension will give you errors and will refuse to compile.

Unpack the imap-2007e.tar.gz file.

In Terminal:

sudo mv ~/Downloads/imap-2007e /usr/local/imap-2007
cd /usr/local/imap-2007
make osx
sudo cp c-client/c-client.a c-client/libc-client.a

Step 2:

Download PHP 5.3.0 source code for the php imap extension here. I already had a copy from my previous extension tutorial, so I just used that copy.

Unpack the file php-5.3.0.tar.gz. We will only need to use the code within the ext/imap directory. No need to compile all of PHP for this.

In Terminal:

cd ~/Downloads/php-5.3.0/ext/imap
phpize
./configure --with-imap==/usr/local/imap-2007 --with-kerberos --with-imap-ssl
make
sudo cp modules/imap.so /usr/lib/php/extensions/no-debug-non-zts-20090626/

Step 3:

Add in the extension location to the php.ini file.

In Terminal:

sudo pico /etc/php.ini

I placed the following after all the commented out lines for extensions:

extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/imap.so

After you have placed that line in there, press Control-X to exit and save.

Step 4:

Restart Apache.

In Terminal:

sudo apachectl graceful

Now you should be able to see the imap extension installed in your stock Apple PHP.

VN:F [1.9.22_1171]
Rating: 7.6/10 (5 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 2 votes)
Snow Leopard PHP and IMAP Support, 7.6 out of 10 based on 5 ratings

9 Comments

  1. Lorenzo
    Posted December 30, 2009 at 3:24 AM | Permalink | Reply

    Followed your instructions thoroughly
    ./configure… fails in step2 with
    configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

    I checked that I had the openssl library installed…

    Do you have any further possible ideas ?
    Thanks
    Lorenzo

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 2 votes)
  2. Chris Peltenburg
    Posted January 8, 2010 at 4:56 PM | Permalink | Reply

    Hi Lorenzo,

    found a solution for your ( and mine too ) problem! Thanks to Alexey Kulikov

    cd imap-2007e/
    make osx EXTRACFLAGS=”-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp”
    sudo mkdir /usr/local/include/
    sudo cp c-client/*.h /usr/local/include/
    sudo mkdir /usr/local/lib/
    sudo cp c-client/*.c /usr/local/lib
    sudo cp c-client/c-client.a /usr/local/lib/libc-client.a

    Then follow the instructions from Step 2

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.22_1171]
    Rating: +3 (from 3 votes)
  3. tedivm
    Posted January 29, 2010 at 1:58 AM | Permalink | Reply

    In step three you should add the path to the “with-imap-ssl” flag-

    ./configure –with-imap=/usr/local/imap-2007 –with-kerberos –with-imap-ssl=/usr/local/ssl

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • Posted April 5, 2010 at 1:20 PM | Permalink | Reply

      Small correction. The path for “with-imap-ssl” is incorrect in comment #3. It should be:

      ./configure –with-imap=/usr/local/imap-2007 –with-kerberos –with-imap-ssl=/usr/

      The configure script only needs “usr” because it appends “include/openssl” to the path that you provide. Also, although it is hard to see with the font of this blog, there are double-hyphens before every occurrence of the word “with” and single hyphens elsewhere.

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.22_1171]
      Rating: +1 (from 1 vote)
  4. Greg
    Posted May 23, 2010 at 6:41 PM | Permalink | Reply

    Thanks! This saved me hours of frustration.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  5. windows95
    Posted November 8, 2011 at 5:56 AM | Permalink | Reply

    Thank you SOOOOOOOOOOOOOOOO much.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  6. Posted November 19, 2011 at 11:55 AM | Permalink | Reply

    When compiling under Mac OSX Lion I got following error:

    /usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory

    I had to do following in order to solve it:

    # cp ../pcre/pcrelib/pcre.h /usr/include/php/ext/pcre/

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  7. Vijay
    Posted July 31, 2012 at 6:03 PM | Permalink | Reply

    For Lion

    http://www.activecollab.com/forums/topic/5844/

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  8. Posted January 8, 2014 at 7:01 PM | Permalink | Reply

    Thank you for these very clear instructions. I am using Snow Leopard as a mail server with postfix, Dove imap, ssl, squirrelmail, etc. I’ve been running php 5 for a long time but am now trying to install the php-imap module. When I got to step 2 and executed the ./configure command you recommend, I got a fatal error:

    . . .
    checking for IMAP support… yes
    checking for IMAP Kerberos support… yes
    checking for IMAP SSL support… yes
    checking for utf8_mime2text signature… new
    checking for U8T_DECOMPOSE…
    configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

    Would you have any suggestions on how to proceed?

    Many thanks in advance.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

3 Trackbacks

  1. [...] First, modified from http://blog.xeonxai.com/2009/12/03/160/: [...]

  2. [...] followed Step 1 from Snow Leopard PHP and IMAP Support article to get IMAP compiled on my Mac (no need to follow the rest of the steps), which made the [...]

  3. [...] PHP 5.4 on Mac OS X Mountain Lion from Source Snow Leopard PHP and IMAP Support PHP Installation On Mac Installation failed with icu-config error on Mac OS X 10.8 Upgrading the [...]

Post a Comment

Your email is never shared. Required fields are marked *

*
*