Installing Mailpile on CentOS 6

I've been meaning to play around with Mailpile since the beta was released back in September. Thanks to a bout of insomnia I finally found time, though it turns out that getting it up and running on CentOS 6 is initially something of a pain.

This documentation details the steps required to install and run Mailpile on CentOS 6

DISCLAIMER: For reasons I'll discuss in a separate post, at time of writing I'd only recommend following these steps if you want to test/play with Mailpile - Personally I don't feel at all comfortable with the idea of using Mailpile in production in it's current state.



Base System

For reference, my install was in a Virtual Machine with the following resources available

  • 1 CPU
  • 256MB RAM
  • Bridged NIC
  • CentOS 6 x86_64 (minimal install)


Installing Python 2.7

This was the first obstacle encountered. Mailpile's wiki states it requires Python >= 2.7, however CentOS 6 only has Python 2.6 available.

Worse, yum requires that specific version, so finding and using an updated RPM is a bad idea (unless you like the idea of yum breaking!). So we need to install Python 2.7 alongside

yum install gcc make wget
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel xz
cd /opt/
wget --no-check-certificate
tar xf Python-2.7.6.tar.xz
cd Python-2.7.6
./configure --prefix=/usr/local
make && make altinstall

The next step is to get pip installed so that we can use it to install Mailpile's dependancies

cd /opt
wget --no-check-certificate
tar xvf setuptools-1.4.2.tar.gz
cd setuptools-1.4.2
python2.7 install
curl | python2.7 -


Install Mailpile (and some dependencies)

We're ready to grab Mailpile. In the command below we're grabbing the beta release, though if you're happy to use the dev branch substitute the branch name with master

yum install git gnupg openssl python-lxml libxslt-devel python-jinja2
cd /usr/local/
git clone -b release/beta
cd Mailpile/
pip install -r requirements.txt

The next step is pretty important - we need to change Mailpile's shebang to ensure it uses Python2.7 and not 2.6

sed -i '1s/python2/python2.7/' mp


Start Mailpile

Our next step is to start Mailpile and then reconfigure it to listen on the external interface and a port of our choosing


mailpile> setup
mailpile> quit
nano ~/.local/share/Mailpile/defaultmailpile.cfg

# Find the following

;http_host = localhost       ; (default) Listening host for web UI
;http_port = 334411           ; (default) Listening port for web UI

# And change to 
http_host =       ; (default) Listening host for web UI
http_port = 80           ; (default) Listening port for web UI

Note: the Mailpile CLI does ostensibly expose a command to configure interface and port (the www command) but it wasn't working for me

Make sure iptables will allow connections through

iptables -I INPUT -p tcp --dport 80 -j ACCEPT
service iptables save

Now we can start Mailpile again (but see the section below)



Choosing a User

Because the steps given above are given to allow testing, I've not followed best practices - Mailpile is running as root when there's really no need to do so. If you're planning on running Mailpile for any length of time, or exposing it to the outside world, or in fact have anything else of value on that server you must run Mailpile as an unprivileged user.

You'll probably also want to create an init script so that Mailpile starts on boot.


Completing the Setup

The final thing to do is to complete Mailpile's configuration.

You should now be able to hit the setup screen in your browser by browsing to the system's IP - follow the steps and Mailpile should be up and running within a few minutes


Troubleshooting: Getting locked out

If after restarting the Mailpile service it tells you that your password is invalid, take a look at this issue