Enable IMAP PHP module on OSX Snow Leopard Server 10.6

avatar specialopssecurity Pro Apr 19. 2010. 1:19 pm
You can safely delete all the extension lines that end with .dll because those are for Windows.

Remove the semi-colon (;) from your extension line referencing imap.so and restart. The semi-colon character makes the line a comment (i.e., ignore this line).
avatar johnk Apr 19. 2010. 3:06 pm
That resolved it, thank you again for all the trouble shooting, this is all very foreign to me. Now just have to figure out why Navicat is adding code interfering with the page ;). Seems like every little step there is something else that happens.
avatar emil_l Jan 18. 2011. 5:38 pm
Hi.

Nice guide but it didn't work fully for me. My main goal was to enable IMAP-SSL to enable my PHP scripts to connect to GMail using IMAP. I have a Core 2 Duo Mac Mini with MAMP installed.

Problem 1.
In Step 6 when trying to build the imap extension I got the following error:
/usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory

Solution
Copy the pcre.h file from the downloaded PHP source to your /usr/include dir:
sudo cp ../pcre/pcrelib/pcre.h /usr/include/php/ext/pcre/

Problem 2
When starting the Apache server again I got the following error in the PHP log:
[18-Jan-2011 22:11:31] PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/imap.so' - dlopen(/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/imap.so, 9): no suitable image found. Did find:
/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/imap.so: mach-o, but wrong architecture in Unknown on line 0

Why?
After hours of searching I figured out that the compiled binary imap.so only contained binary for the x86_64 architecture. My MacMini has a 64-bit CPU so the problem isn't there. The problem is that the php binary shipped with MAMP is only built for the i386 architecture, making them incompatible.

How:
If you run the command 'lipo -info <filename>' you will see which architectures the binary supports. Try running it on file php-5.3.1/ext/imap/modules/imap.so and compare the output with the php binary located in /Applications/MAMP/bin/php5.3/bin/

Solution:
Rebuild the imap extension, this time targeted for both i386 and x86_64 architectures. We have to rerun step 5 with some modifications:
cd php-5.3.1/ext/imap
make clean
phpize
MACOSX_DEPLOYMENT_TARGET=10.6 \
CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" \
CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" \
CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" \
LDFLAGS="-arch i386 -arch x86_64 -bind_at_load" \
./configure --with-imap=/usr/local/imap-2007 --with-kerberos --with-imap-ssl=/usr/

Then continue with step 6.

It took me about 15 painstaking hours to figure this out. Hope I can help someone out there so you don't have to go through the same frustrating process I had to go through.
avatar mathias.lin Jul 9. 2011. 12:52 pm
(post deleted - I missed emil_l's comment on the second page, which solved my problem actually. Thanks, saved me lots of time!)
avatar ebatte Pro Aug 24. 2011. 10:23 am
[sigh]

I'm getting the following errors attempting to make the module in OS X 10.6.8. If anyone could assist I would appreciate it.

/Users/admin/Downloads/php-5.3.8/ext/imap/php_imap.c:554: error: 'PHP_FE_END' undeclared here (not in a function)
/Users/admin/Downloads/php-5.3.8/ext/imap/php_imap.c:561: error: 'ZEND_MOD_END' undeclared here (not in a function)
/Users/admin/Downloads/php-5.3.8/ext/imap/php_imap.c:562: error: initializer element is not constant
/Users/admin/Downloads/php-5.3.8/ext/imap/php_imap.c:562: error: (near initialization for 'imap_deps[1].name')
make: *** [php_imap.lo] Error 1

Thanks
Eric
avatar tonyswu Sep 22. 2011. 6:11 pm
Hi ebatte,

The instructions posted only works with PHP source version5.3.0. You can't find the older version on PHP's official site anymore, but if you google it you can find it somewhere.
avatar ebatte Pro Sep 27. 2011. 9:09 am
tonyswu:
Hi ebatte,

The instructions posted only works with PHP source version5.3.0. You can't find the older version on PHP's official site anymore, but if you google it you can find it somewhere.


My Snow Leopard Server is running 5.3.4 according to info.php. Is it important that the versions match exactly when following these instructions or do I have to find 5.3.0?

And just to clarify, you're saying 5.3.0 is required for the imap module and not to have 5.3.0 running on the server?
avatar helpdesk Pro Nov 1. 2011. 9:52 pm
Yeah, you need the source code of PHP 5.3.0 in order to compile the IMAP module following this guide. You don't necessarily have to run PHP 5.3.0 on your server. My web server is running PHP 5.4 currently, and the PHP module compiled with PHP 5.3.0 source code works out perfectly.

Try activeCollab free for 30 days, No credit card required!

Instant access to activeCollab, no installation needed.

.tryactivecollab.com

If you are already a user of activeCollab, you can log in here.