← ServerPilot Docs

How to Install the PHP Mailparse Extension

In the examples shown, replace "X.Y" with your app's PHP version (for example, "5.6" or "7.0"). To install this extension for multiple PHP versions, repeat the installation for each PHP version.

The PHP mailparse extension provides functions for parsing and working with email messages. It can deal with RFC 822 and RFC 2045 (MIME) compliant messages. Mailparse is stream-based, meaning it does not keep in-memory copies of the files it processes and so is very resource efficient when dealing with large messages.

Install Mailparse on PHP 7.3 and 7.4

The mailparse extension does not yet support PHP 7.3 or 7.4.

Install Mailparse on PHP 7.0, 7.1, or 7.2

To install this extension on PHP 7.X, SSH in to your server as root and run the following commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo pecl7.X-sp install --nodeps mailparse
sudo bash -c "echo extension=mailparse.so > /etc/php7.X-sp/conf.d/mailparse.ini"
sudo service php7.X-fpm-sp restart

Install Mailparse on PHP 5.4, 5.5, or 5.6

To install this extension on PHP 5.X, SSH in to your server as root and run the following commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo pecl5.X-sp install --nodeps mailparse-2.1.6
sudo bash -c "echo extension=mailparse.so > /etc/php5.X-sp/conf.d/mailparse.ini"
sudo service php5.X-fpm-sp restart

Verify the Installation

You can verify the mailparse extension is installed by running this command:

phpX.Y-sp -i | grep mailparse

You should see output such as the following:

/etc/phpX.Y-sp/conf.d/mailparse.ini,
mailparse
mailparse support => enabled
mailparse.def_charset => us-ascii => us-ascii

Uninstalling the MailParse Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/mailparse.ini
sudo peclX.Y-sp uninstall mailparse

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart
Last updated: October 8, 2018

Launch your first site in 5 minutes