Installing PHP Mailparse
From Cerberus Helpdesk Wiki
If your PHP5 environment doesn't already have the 'mailparse' extension installed then you'll need to add it
Contents |
On Unix-based Servers
Using PECL
Generally, installation can be accomplished with a simple command at the server console:
pecl install mailparse
This should retrieve, compile and install the extension. You'll usually need to enable the mailparse extension in your php.ini file by hand. This is accomplished in various ways for different OS/distributions.
In most cases you can simply add the following line to your php.ini:
extension=mailparse.so
FreeBSD Issue
You may need to edit the pecl script (usually /usr/local/bin/pecl) and remove the ā-nā from the command line arguments.[1]
For RHEL 5
RHEL 5 Only supports 5.1.6 you will need to upgrade your php to 5.2+. The older instructions are no longer valid as of 4.3.0.
If your installed version of PHP does not match the system installed version, then these steps can fail with the following error in your PHP log:
PHP Warning: PHP Startup: mailparse: Unable to initialize module Module compiled with module API=[date1], debug=0, thread-safety=0 PHP compiled with module API=[date2, debug=0, thread-safety=0 These options need to match in Unknown on line 0
If you are using SeLinux to protect your system, you will need to change selinux security context of the mailparse.so. PHP will be able to load the extension, but SeLinux will prevent php from using it.
to check the security context: getfattr -n security.selinux /path/to/your/mailparse.so if you don't get something like this security.selinux="system_u:object_r:textrel_shlib_t:s0\000", your must change it. to change the security context: sudo setfattr -n security.selinux -v "system_u:object_r:textrel_shlib_t:s0\000" /path/to/your/mailparse.so
RHEL6/CentOS6
Installing mailparse on RHEL6 based distributions is easy if you enable the EPEL repository.
su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm' su -c 'yum install php-pecl-mailparse'
From source code
http://www.cerb4.com/forums/showthread.php?t=40
Contributed by: BlueC (Cerb4 Forums)
Ubuntu (Debian) LAMP-based install
http://forums.cerb4.com/showthread.php?t=244
Contributed by: alamb (Cerb4 Forums)
Mac OS X (XAMPP)
- Download and install the 'Developer Tools' package from http://www.apachefriends.org/en/xampp-macosx.html
- From the console:
sudo /Applications/XAMPP/xamppfiles/bin/pear install pecl/mailparse
On Windows-based Servers (XAMPP)
If you're using XAMPP, or a similar distribution, you probably already have the mailparse extension available. Note that XAMPP 1.71 is the latest version to ship with mailparse.
If you do not have php_mailparse.dll, you can download it from:
- http://downloads.php.net/pierre/ (PHP versions below 5.3)
- http://www.rene-schwarz.com/web/Blog:Personal/php_mailparse.dll_for_PHP_5.3.x (PHP version 5.3.x, build with VC6)
- http://www.rene-schwarz.com/web/Blog:EN/php_mailparse.dll_for_PHP_5.3.6_and_above_%28VC9_version%29_available (PHP version 5.3.x, build with VC9 - standard since PHP 5.3.6)
- Edit your php.ini file (use http://localhost/cerb4/install/phpinfo.php to identify the correct php.ini file, since it is not unusual to have several different ones)
- Remove the ';' in front of the line:
;extension=php_mailparse.dll
- Save your php.ini file
- Restart Apache
On Windows-based Servers (IIS)
http://www.cerb4.com/forums/showthread.php?t=154
(Contributed by TravisT)
Additional Notes
mbstring before mailparse
Also don't forget to load the mbstring extension before you load mailparse.
For example, in the php.ini place in this order:
extension=php_mbstring.dll extension=php_mailparse.dll
Or you will get an error.
Contributed by: Mustafa
CentOS issues
http://www.cerb4.com/forums/showthread.php?t=25&highlight=centos
Contributed by: brwatters
Configure Error
If you get the "checking whether the C compiler works... configure: error: cannot run C compiled programs." error, check the mount permissions on your /tmp directory. You may need to remount /tmp as executable.
# mount | grep /tmp /dev/sda3 on /tmp type ext3 (rw) /tmp on /var/tmp type none (rw,noexec,nosuid,bind) # mount -o remount,exec,suid /tmp
do your compiling, then
# mount -o remount,noexec,nosuid /tmp
Contributed by Alex in Community Town Hall
mailpars2em
If you cannot install the Mailparse extension, a member on the forums has written PHP emulation called "mailpars2em" which uses the freely available PEAR package "Mail/mimeDecode" instead of Mailparse. No compilation is required, but since it is not compiled C code, it runs more slowly than Mailparse. You can download mailpars2em, under an "experimental, use at your own risk" agreement. For more information, see this forum thread.
Contributed by Kitchin in Forums