Setup iRedMail on FreeBSD 10

This tutorial will show you how to install the groupware iRedMail on a fresh installation of FreeBSD 10.

You should use a server with at least one gigabyte of memory, preferably even two. While the software doesn’t use many resources when idling, it peaks very fast when under load. For example, during virus scans.

Important: Please do not try to install iRedMail on a system that’s already in production. It’s designed to be installed on a fresh installation and will override other MTAs when it finds them. Please be cautious and always have backups at hand.

For the course of this tutorial, we will assume that you are working as the administrative user. If you want to use sudo Instead, then you will have to append it where necessary.

Change Hostname

First, make sure that a fully qualified domain name is set by opening /etc/rc.conf with your favorite text editor and replacing the value there with an FQDN:

hostname="mail.example.com"

Next, make sure that the FQDN is the first value listed in /etc/hosts:

127.0.0.1   mail.example.com mail localhost localhost.localdomain

Verify that everything worked by issuing hostname -f. The output should be:

mail.example.com

The only dependency of iRedMail is bash-static (and wget to fetch it), which can be found in the official pkg-repositories:

pkg
pkg update -f
pkg install bash-static

Since the installation script builds everything from FreeBSD’s ports tree, you need to fetch it:

portsnap fetch extract

Due to some complications with the Apache versioning from FreeBSD 10 upwards, you need to add the following to /etc/make.conf to ensure that the installation script works:

DEFAULT_VERSIONS=apache=2.2

Download and install iRedMail

Download and unpack the latest version from the official homepage:

wget https://bitbucket.org/zhb/iredmail/downloads/iRedMail-0.8.7.tar.bz2
tar -xf iRedMail-0.8.7.tar.bz2

Change the permissions of the script, and run the installer:

cd iRedMail-0.8.7/
chmod 700 iRedMail.sh
./iRedMail.sh

The installation script will ask you some questions:

The installer will now prompt you about a file with sensitive information in it. /root/iRedMail-0.8.7/config. Make sure to properly set the file permissions when the installation is finished:

chmod 600 /root/iRedMail-0.8.7/config

The installation script installs a lot of packages, and it may take some time to complete since everything is being built from source.

Now you’ll be prompted with all the necessary information to use iRedMail – after a reboot:

reboot

(Don’t worry, the prompted information can be found in /root/iRedMail-0.8.7/iRedMail.tip after the reboot.)

The webmail interface can now be accessed with your web browser at:

https://mail.example.com/mail

Install Certificate Authority

However, since iRedMail uses a certificate that’s not issued by a legitimate certificate authority (CA), you will most likely get a security warning from your browser. If you would like to remove the security warning, then you will need to obtain a certificate from a trusted CA. Installing a different certificate requires both the certificate and the private key. Once uploaded to your server, these files can be copied to the proper location with the following commands:

cp /path/to/your/cert /etc/ssl/certs/iRedMail_CA.pem
cp /path/to/your/key /etc/ssl/private/iRedMail.key

Then, restart everything that uses the cert/key:

service postfix restart
service dovecot restart
service apache2 restart

And now you have an all-in-one mail solution. Happy mailing!

Other Versions

Debian