If you are in a search for an email archiving solution, MailPiler is a recommend solutions.

If you didn't heard about MailPiler, check out the comparison with MailArchiva for a full list of features.

Unfortunately, install documentation is missing some details for specific Debian versions, so here is our updated guide.

This document is targeted at advanced users, so it might miss some obvious bits and pieces for a daily SysAdmin.

Note: There are some missing packages on Debian 9.x Stretch, so we recommend Debian Jessie instead.

It might work with Ubuntu or other Debian derivatives.

In the following guide, we'll use mailarchive.example.com as the FQDN of the email archiving server.

You should replace it with your own hostname and your own domain. Make sure you have a public DNS record pointing to the server.

The web application will be available on port 8080 instead of 80.

Note: Make sure you are familiar with install documentation.

Step 1: OS and Preparation

  • Install Debian 8.x Jessie
  • Setup a large disk space for /var
  • Select only SSH Server and optionally, standard system utilities packages
  • Make sure the hostname matches your FQDN:
cat /etc/hostname
mailarchive
cat /etc/hostname
127.0.0.1   localhost
127.0.0.1   mailarchive.example.com mailarchive
cat /etc/mailname
mailarchive.example.com

Step 2: Initial Setup

# Optional: Set APT to not recommended packages
echo -e "APT
{
\tInstall-Recommends "false";
}
" > /etc/apt/apt.conf.d/20norecommends
# Removing default packages
apt -y purge bind9 eject manpages-de manpages-es manpages-fr manpages-it manpages-pl manpages-pt vim vim-common vim-runtime vim-tiny exim4-base exim4-config exim4-daemon-light
# Setting up repository: Debian Jessie
echo -e "deb http://ftp.debian.org/debian jessie main contrib non-free
deb http://ftp.debian.org/debian/ jessie-updates main contrib non-free
deb http://security.debian.org/ jessie/updates main contrib non-free" > /etc/apt/sources.list
# Setting up repository: Debian Jessie Backports
echo "deb http://http.debian.net/debian jessie-backports main" > /etc/apt/sources.list.d/backports.list
# Updating system
apt -y update && apt -y upgrade
# Installing some tools and utilities
apt -y install sudo curl htop mc ntp ntpdate locate unzip file lftp figlet mtr-tiny dialog dnsutils lsb-release ca-certificates bash-completion

Step 3: Pre-install

See install documentation for details.

apt -V install apache2 apache2-utils build-essential catdoc checkinstall gettext libapache2-mod-php5 libltdl7 libmysqlclient-dev libmysqlclient18 libodbc1 libpq5 libpst4 libssl-dev libtre-dev libtre5 libwrap0-dev libzip2 memcached mysql-client mysql-common mysql-server openssl php5-curl php5-gd php5-ldap php5-memcache php5-mysql poppler-utils sysstat tnef unrtf

Step 4: Add piler user

groupadd piler
useradd -g piler -m -s /bin/sh -d /var/piler piler
usermod -L piler
chmod 755 /var/piler

Step 5: Setup Apache2

We'll remove the default-site and default ports, and setup a single virtual host on port 8080.

mkdir -p ~/config-backup/apache2
mv /etc/apache2/ports.conf ~/config-backup/apache2
touch /etc/apache2/ports.conf

a2dissite 000-default
a2enmod rewrite
```

AllowOverride for /var/piler/www

cat /etc/apache2/conf-available/piler-override.conf
<Directory /var/piler/www/>
        Options Indexes FollowSymLinks
        AllowOverride All 
        Require all granted
</Directory>
a2enconf piler-override

Add Apache2 site configuration, see /contrib/webserver/piler-apache-2.x.conf

cat /etc/apache2/sites-available/piler.conf
NameVirtualHost *:8080
Listen 8080

<VirtualHost *:8080>
    ServerName mailarchive.example.com

    DocumentRoot "/var/piler/www"

    <Directory /var/piler/www>
        Require all granted
        AllowOverride all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/mailarchive.example.com_error.log
    CustomLog ${APACHE_LOG_DIR}/mailarchive.example.com_access.log combined
</VirtualHost>
a2ensite piler

Do not restart Apache2 yet.

Step 6: Get and unpack the installation archive

wget --no-check-certificate https://bitbucket.org/jsuto/piler/downloads/piler-1.3.4.tar.gz
tar zxvf piler-1.3.4.tar.gz
cd piler-1.3.4

Step 7: Start cooking

./configure --localstatedir=/var --with-database=mysql --enable-tcpwrappers

It seems there is an error on postinstall.sh, so you should replace @sh with @bash.

sed -i "s|@sh |@bash |g" Makefile
make
su -c 'make install'
ldconfig

Step 8: Start postinstall

Do not forget your MySQL root password and generate a password for MySQL piler user.

make postinstall

Use www-data as webserver group.

Make sure the process finish without errors.

Step 9: (Auto)start services

cd init.d
make install
update-rc.d rc.piler defaults
update-rc.d rc.searchd defaults

Optionally, set SMTP banner id hostid:

sed -i "s|hostid=piler.yourdomain.com|hostid=mailarchive.example.com|g" /usr/local/etc/piler/piler.conf

Start services

service rc.searchd start
service rc.piler start

Step 10: Starting web application

If you have an error about ${prefix}/etc/piler/config-site.php replace in/var/piler/www/config.php`:

require_once '${prefix}/etc/piler/config-site.php';

with

require_once dirname(__FILE__) . '/config-site.php';

Update your web application config:

cat /var/piler/www/config-site.php
<?php

$config['SITE_NAME'] = 'mailarchive.example.com';
$config['SITE_URL'] = 'http://' . $config['SITE_NAME'] . ':8080';
$config['DIR_BASE'] = '/var/piler/www/';

$config['SMTP_DOMAIN'] = 'mailarchive.example.com';
$config['SMTP_FROMADDR'] = 'no-reply@mailarchive.example.com';
$config['ADMIN_EMAIL'] = 'admin@mailarchive.example.com';

$config['DB_USERNAME'] = 'piler';
$config['DB_DATABASE'] = 'piler';
$config['DB_PASSWORD'] = '';

$config['TIMEZONE'] = 'Europe/Bucharest';

You can check default values in /var/piler/www/config.php.

Give permission to the webserver to write the tmp/ directory (Do not confuse it with the system /tmp directory!)

chown www-data:www-data /var/piler/www/tmp

Restart Apache2

service apache2 restart

Switch to your browser and navigate to http://mailarchive.example.com:8080.

Default login is admin@local:pilerrocks.

Step 11: Configure your Postfix mail server to forward a copy of each email it receives or sends

Note: As a security guideline, make sure your firewall accepts incoming connections on port 25 only from desired Postfix instances.

On Postfix, setup always_bcc to your mailarchive.example.com:

nano /etc/postfix/main.cf
always_bcc = archive@mailarchive.example.com

Don't forget to check syslog on both servers for any possible errors :)

Also, if you're need our support, you can contact us.