Install Mailparse

December 31, 2009 by: Akhthar Parvez

Mailparse is a PECL (PHP Extension Community Library) extension for parsing emails. You should have the PHP module mbstring for mailparse to work. It’s a pretty straightforward task. Run the following command to install mailparse:

# pecl install mailparse

If you get the following error whle compiling mailparse:

checking whether the C compiler works… configure: error: cannot run C compiled programs.

Check the mount permission on your /tmp directory. You would 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

Proceed with the compilation and don’t fforget to remount /tmp as noexec once it’s finished.

# mount -o remount,noexec,nosuid /tmp

If you you don’t want to remount /tmp as noexec even temporarily or can’t remount /tmp (chance if you’re on VPS), you can use another directory for temp.

# pear config-set temp_dir /var/tmp/pear/temp

You may proceed with the installation now and that should work.

Manual installation:

If the automatic compilation doesn’t work and you have no idea how to fix it, don’t panic. You can install it manually.

1. Download the package from http://pecl.php.net/package/mailparse

2. Hand compile it.

# tar -zxvf mailparse-*.tgz
# cd
mailparse-*
# phpize
# ./configure
# make
# make install

3. Move the module mailparse.so to the PHP extensions directory and add the following line under Dynamic Extensions in your php.ini

extension=mailparse.so

Restart Apache and Mailparse is compiled into the PHP now.

Leave a Reply

You must be logged in to post a comment.