Installing PHP Mailparse

From Cerberus Helpdesk Wiki

Jump to: navigation, search

If your PHP5 environment doesn't already have the 'mailparse' extension installed then you'll need to add it

Contents

[edit] On Unix-based Servers

[edit] 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

[edit] 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]

[edit] For RHEL 5

wget http://dag.wieers.com/rpm/packages/php-pecl-mailparse/php-pecl-mailparse-2.1.1-1.el5.rf.i386.rpm
rpm -i php-pecl-mailparse-2.1.1-1.el5.rf.i386.rpm
service httpd reload

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

To fix this you will need to first remove the RPM version of MailParse then compile MailParse automatically with pecl. Since mbstring is likely installed as an RPM, rather than through pecl, it won't recognize it as being already installed. As a result of this you must use the '-n' (no dependencies) flag when installing with pecl.

rpm -e php-pecl-mailparse
pecl install -n mailparse

[edit] From source code

http://www.cerb4.com/forums/showthread.php?t=40

Contributed by: BlueC (Cerb4 Forums)

[edit] Ubuntu (Debian) LAMP-based install

http://www.cerb4.com/forums/showthread.php?t=244

Contributed by: alamb (Cerb4 Forums)

[edit] On Windows-based Servers (XAMPP)

If you're using XAMPP, or a similar distribution, you probably already have the mailparse extension available.

;extension=php_mailparse.dll
  • Save your php.ini file
  • Restart Apache

[edit] On Windows-based Servers (IIS)

http://www.cerb4.com/forums/showthread.php?t=154

(Contributed by TravisT)

[edit] Additional Notes

[edit] 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

[edit] CentOS issues

http://www.cerb4.com/forums/showthread.php?t=25&highlight=centos

Contributed by: brwatters

[edit] 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


[edit] External Links

Personal tools