Mbstring not found error while installing mailparse PHP extension

Today I had to install mailparse via PEAR. On installing I came across one of the errors: mbstring not found despite of it was right there. One of the simplest option to fix it is given below.

Though I am working on MAMP but it will work with anyone since it’s part of PHP Source.

Go to your PHP Source Library. In my case it is:

/Applications/MAMP/bin/php/php7.0.8/include/php/ext/mbstring/libmbfl/mbfl

and add following lines in mbfilter.h

#undef HAVE_MBSTRING
#define HAVE_MBSTRING 1

and then run PEAR command again

pear install pecl/mailparse

If all goes well it should give something like:

Build process completed successfully
Installing '/Applications/MAMP/bin/php/php7.0.8/lib/php/extensions/no-debug-non-zts-20151012/mailparse.so'
install ok: channel://pecl.php.net/mailparse-3.0.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=mailparse.so" to php.ini

Manually add entry of the extension in your php.ini file and it should be available for work.