By now your Debian Wheezy server should be readily installed. Now it’s time to install the necessary Debian packages to make it an actual mail server.
It is a good idea to install all missing security updates first:
Debian Wheezy does not install the SSH server by default. So to spare you an extra walk to the server room I suggest:
apt-get install ssh
Then let’s install Postfix with MySQL backend support:
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).
As by default Debian installs exim as a mail service you should remove its remains:
apt-get –purge remove ‘exim4*’
A very useful tool is SWAKS (the SWiss Army Knife for Smtp):
apt-get install swaks
You also need a MySQL server:
apt-get install mysql-server
Note: You can run MySQL server on the same system as your actual mail service – but don’t have to. The mail server can communicate with the MySQL server via TCP networking. Maybe you even have a MySQL server in your network already that you can use.
During the installation you will get asked for the password of a newly created “root” user. This is not your system’s “root” login but a special administrative user used to access the MySQL server. Choose a secure password you want and write it down. (Use “pwgen -s 25 1” or “apg -m 25 -a 1 -n 1” to get good passwords. The commands are available once you “apt-get install pwgen apg”.)
And another warning: during the installation a MySQL user account called “debian-sys-maint” will be created with a random password. The password is stored in the /etc/mysql/debian.cnf file. Do not touch this file or change the user’s password in the database or you won’t be able to stop or start the MySQL service any more.
You will want to offer POP3 and IMAP services to your users so you need to install Dovecot’s services:
apt-get install dovecot-mysql dovecot-pop3d dovecot-imapd dovecot-managesieved
If you intend to offer a webmail service I can recommend the Roundcube package. Previous versions of the tutorial recommended Squirrelmail but honestly Roundcube is way more comfortable. Type:
apt-get install roundcube roundcube-plugins
This will also install an Apache server and PHP packages. You will get asked if you want to maintain the RoundCube package using “dbconfig-common”. Basically this means that Debian will set up the database for you and in future releases upgrade the database. I suggest you say “Yes” here. The database type is “MySQL”. When asked for the “database’s administrative user’s password” enter the password you entered for the MySQL “root” user when you installed the MySQL server. Then you will have to think of a safe password that RoundCube will use to access its database and enter that twice.
If you believe you are not a MySQL ninja on the command line then I suggest you install the PHPMyAdmin software which allows you to manage your MySQL database in the web browser:
apt-get install phpmyadmin
Again you are asked if you want to manage the phpmyadmin database using “dbconfig-common”. Answer “yes”, enter the MySQL “root” user’s password. You will get asked for a “MySQL application password for phpmyadmin”. Just leave the field empty and continue – a password will be generated automatically. As a web server to be used select “apache2”.
Now all basic packages are installed and it’s time to prepare the database in the next chapter.