Your server should now be booted up and ready. You can now login at the console. But I personally prefer to login from my workstation via SSH. Use the “johndoe” user (or whatever you named it) to login.
To become root and be able to install software packages run…
…and enter the root password.
Unless you just installed the server it is a good idea to install all missing security updates first:
apt-get update apt-get upgrade
Let us install the necessary Debian packages to make it an actual mail server. You will install:
The MySQL server that will store information about your email accounts and domains.
The MTA (mail transport agent) that speaks SMTP and receives and sends emails.
An extension that allows Postfix to get its information from a MySQL database.
The IMAP/POP3 mail server including an extension to get its information from a MySQL database.
An extension to Dovecot that allows users to fetch emails using the POP3 protocol. (This is optional. Only few users if any will use POP3.)
An extension to Dovecot that allows users to access emails using the IMAP protocol.
Enabled Dovecot to receive LMTP connections. We will need it later to allow email communication between Postfix and Dovecot.
An extension to Dovecot that allows users to define filter rules that are automatically run on the server when a new email arrives.
A PHP-based web interface to manage your MySQL database.
A software to score emails. Helps you determine how likely an email is spam.
An extension that allows communication between SpamAssassin and Postfix using the milter protocol.
A tool to create passwords. (Optional.)
A PHP-based webmail software. (Optional.)
Extra plugins that add functionality to Roundcube. (Optional.)
The SWiss Army Knife of Smtp. A utility to send emails through SMTP for testing purposes.
Let’s start with the pwgen utility. It helps you create secure passwords:
apt-get install pwgen
Create a password to be used for the administrative access to the MySQL in the next step:
pwgen -s 20 1
You will get a random string like “W2EzNUFJzjEmA8tQT7A0”. Copy it into your clipboard (e.g. by selecting it with your mouse).
Next install the MySQL server package:
apt-get install mysql-server
The MySQL package is installed and a new MySQL user called “root” will be created. You will get asked which password the MySQL root user should get:
Paste the password (e.g. by clicking the middle mouse button) from pwgen. From now on you need that password to access the MySQL server. But this can get annoying. For your convenience create a file /root/.my.cnf like:
As the password use your own pwgen-created password. To make the file only readable for the system’s “root” user run:
chmod u=rw,go= /root/.my.cnf
If all went well you can now run “mysql” and get a connection to your MySQL database:
Exit the MySQL shell with “exit” or just press CTRL-D.
Now on to the Postfix packages:
apt-get install postfix postfix-mysql
When you get asked for the mail server configuration type please choose “Internet site”. Enter your own mail server name (the fully qualified domain name) or just press enter. The host name and domain does not need to match any of your email domains.
By default Debian installs exim as a mail service. I suggest that you remove its remains:
apt-get --purge remove 'exim4*'
Our new way to deal with spam is ussing SpamAssassin and it’s “milter“:
apt-get install spamassassin spamass-milter
A very useful tool to test email delivery later is SWAKS (the SWiss Army Knife for Smtp):
apt-get install swaks
In addition to Postfix (that handles SMTP communication) you will need Dovecot to store received emails and allow IMAP (and optionally POP3) access for your users:
apt-get install dovecot-mysql dovecot-pop3d dovecot-imapd dovecot-managesieved dovecot-lmtpd
If you intend to offer a webmail service I can recommend the Roundcube package. Unfortunately Debian Jessie does not provide Roundcube in its main package repository. The package maintainers and the release team were not happy with the quality of the packages at the time that Jessie was released. So it was decided to leave out Roundcube. Fortunately the debian-backports repository provides ready packages. To add the backports repository you need to create a new file /etc/apt/sources.list.d/jessie-backports.list and put…
deb http://http.debian.net/debian jessie-backports main
…into it. Update your package index:
…and you will be able to install the packages. Type:
apt-get install roundcube roundcube-plugins
Roundcube also creates a small MySQL database to store its management information. So you will be asked whether that database should be configured automatically for you:
Answer “yes”. As the database type we will use “mysql”:
The installer once again needs your MySQL “root” user’s password:
And it will create a non-admin MySQL user with just access to that new database. The password of that user does not matter so just press “Enter”:
Now all required packages are installed. They are not configured though. That is what we will deal with on the next pages.