4

On 31st of March Homebrew moved some of their formulas around. For this reason I can't find a way to make my PHP 7 work with the following extensions:

mailparse
imap

I have tried many examples found on the internet, such as

  • brew install php70 --with-imap
  • brew install -s php70 --with-imap
  • brew install php70-imap

not mentinoning the brew update, brew upgrade, brew tap etc...

But none of them seems to work as brew php does not work with options anymore.

I had even less options trying to install without homebrew, as I am using nginx in my computer, not apache.

Does any one had this problem and was able to fix it?

Thanks!

1 Answer 1

6

After some troubleshooting, it finally worked..... That's how I did:

First I installed the following formulas:

brew install imap-uw
brew install openssl

After that, I downloaded the same version of the pho is running in my computer on http://php.net/downloads.php (saved it in Downloads folder).

In terminal I did.

cd ~/Downloads/php-7.0.29/ext/imap
./configure --with-imap=/usr/local/Cellar/imap-uw/2007f --with-kerberos --with-imap-ssl=/usr/local/opt/openssl
make

where /usr/local/Cellar/ is the path where the formula imap-uw is installed.

P.S this configure file does not accept --with-openssl or --with-openssl-dir or +openssl. I waist a lot of time trying that.

it created a folder modules/ with the imap.so file inside.

Then I created a folder and moved the imap file to inside it

mkdir /usr/local/opt/php70-imap
mv modules/imap.so /usr/local/opt/php70-imap/imap.so

After that just add the extension to the php.ini file

extension="/usr/local/opt/php70-imap/imap.so"

Restart the server and imap will work fine!

For mailparse I had to use pecl.

First I followed this tutorial https://jason.pureconcepts.net/2012/10/install-pear-pecl-mac-os-x/

After pecl was installed properly in my computer, I ran the following code:

cd
pecl download mailparse
tar -xvf mailparse-3.0.2.tgz 
cd mailparse-3.0.2/
phpize
./configure
sed -i 's/#if\s!HAVE_MBSTRING/#ifndef MBFL_MBFILTER_H/' ./mailparse.c
make
mkdir /usr/local/opt/php70-mailparse
sudo mv modules/mailparse.so /usr/local/opt/php70-mailparse/mailparse.so

I got the piece of code above here https://github.com/php-mime-mail-parser/php-mime-mail-parser . However the line sed -i 's/#if\s!HAVE_MBSTRING/#ifndef MBFL_MBFILTER_H/' ./mailparse.c has not worked properly. I ran make anyways and it worked.

After that just add the extension to the php.ini file

extension="/usr/local/opt/php70-mailparse/mailparse.so"
3
  • Where is the modules/ folder created?
    – Bryan L
    Commented Sep 12, 2018 at 16:31
  • Same folder where you run the pecl @BryanLamtoo Commented Sep 12, 2018 at 20:02
  • This is what I did to overcome the sed error: sed -i '' 's/\#if\s!HAVE_MBSTRING/#ifndef MBFL_MBFILTER_H/' ./mailparse.c
    – Mr Mikkél
    Commented Jan 10, 2020 at 1:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.