How to re-compile imap.so with SSL enabled for MAMP Pro (Mac), macOS Sierra

 

Steps for re-compiling imap.so

 

1. Download imap source

$ cd ~/Downloads
$ wget -c ftp://ftp.cac.washington.edu/imap/imap-2007f.tar.gz
$ rm -rf imap-2007f
$ tar xvvfz imap-2007f.tar.gz
$ cd imap-2007f
$ nano Makefile

2. Find the text osx: and replace SSLINCLUDE=/usr/include/openssl to SSLINCLUDE=/usr/local/opt/openssl/include/openssl

osx:    osxok an
        $(TOUCH) ip6
        $(BUILD) BUILDTYPE=$@ IP=$(IP6) EXTRAAUTHENTICATORS="$(EXTRAAUTHENTICATORS) gss" \
        SPECIALS="SSLINCLUDE=/usr/local/opt/openssl/include/openssl SSLLIB=/usr/lib SSLCERTS=/System/Library/OpenSSL/certs SSLKEYS=/System/Library/OpenSSL/private GSSINCLUDE=/usr/include GSSLIB=/usr/lib"

3. Compile c-client.a and copy to /usr/local/imap

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

4. Go to php imap extension folder and compile imap.so

$ cd /Applications/MAMP/bin/php/php5.6.10/include/php/ext/imap/
$ /Applications/MAMP/bin/php/php5.6.10/bin/phpize
$ ./configure --with-imap=/usr/local/imap-2007f --with-kerberos --with-imap-ssl --with-php-config=/Applications/MAMP/bin/php/php5.6.10/bin/php-config
make
$ cp modules/imap.so /Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226

5. Edit php.ini

extension=imap.so

 

Same steps for 7.0.8

 

References: