Install the software packages

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…

su -

…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:

  • mysql-server
    The MySQL server that will store information about your email accounts and domains.
  • postfix
    The MTA (mail transport agent) that speaks SMTP and receives and sends emails.
  • postfix-mysql
    An extension that allows Postfix to get its information from a MySQL database.
  • dovecot-mysql
    The IMAP/POP3 mail server including an extension to get its information from a MySQL database.
  • dovecot-pop3d
    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.)
  • dovecot-imapd
    An extension to Dovecot that allows users to access emails using the IMAP protocol.
  • dovecot-lmtpd
    Enabled Dovecot to receive LMTP connections. We will need it later to allow email communication between Postfix and Dovecot.
  • dovecot-managesieved
    An extension to Dovecot that allows users to define filter rules that are automatically run on the server when a new email arrives.
  • phpmyadmin
    A PHP-based web interface to manage your MySQL database.
  • spamassassin
    A software to score emails. Helps you determine how likely an email is spam.
  • spamass-milter
    An extension that allows communication between SpamAssassin and Postfix using the milter protocol.
  • pwgen
    A tool to create passwords. (Optional.)
  • roundcube
    A PHP-based webmail software. (Optional.)
  • roundcube-plugins
    Extra plugins that add functionality to Roundcube. (Optional.)
  • swaks
    The SWiss Army Knife of Smtp. A utility to send emails through SMTP for testing purposes.
  • mutt
    A console-based program that can speak IMAP and also read Maildirs directly. Very helpful for testing the functionality of your mail server.

MySQL server

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:

ispmail-jessie-install-packages-mysql-root-password

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:

[client]
password=W2Ez…

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:

ispmail-jessie-install-packages-mysql-root-connection

Exit the MySQL shell with “exit” or just press CTRL-D.

Postfix

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

Dovecot

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

Roundcube

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:

apt-get update

…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:

ispmail-jessie-install-packages-roundcube-dbconfig

Answer “yes”. As the database type we will use “mysql”:

ispmail-jessie-install-packages-roundcube-dbconfig-dbtype

The installer once again needs your MySQL “root” user’s password:

ispmail-jessie-install-packages-roundcube-dbconfig-root

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”:

ispmail-jessie-install-packages-roundcube-dbconfig-adminuser

Now all required packages are installed. They are not configured though. That is what we will deal with on the next pages.

18 thoughts on “Install the software packages”

  1. Frederik Vanrenterghem

    Hi Christoph,

    The dovecot installation section omits dovecot-lmtpd from the apt-get install command.

    Best regards,
    Frederik

      1. Frederik Vanrenterghem

        Just trying to troubleshoot my setup, so I’m jumping back and forth in the tutorial. It didn’t get installed when I executed apt-get install dovecot-mysql dovecot-pop3d dovecot-imapd dovecot-managesieved originally. I don’t see it in the dependencies of these either – should it be?

        1. Christoph Haas

          My bad. I listed it in the packages to be installed but forgot to add it to the “apt-get install …” command. I have fixed it.

  2. “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”:”

    Why doesn’t it matter?
    won’t it create a mysql user with no password anyone can use to mess with roundcube?

      1. I think it would be worth mentioning that in your description. That also shook me a little bit. So I’d recommend something like, “doesn’t matter because a random password is generated anyway” or something to that effect.

  3. Hi,
    I get stuck with the spamassassin installation on my newly installed jessie system:
    Setting up sa-compile (3.4.0-6) …
    Running sa-compile (may take a long time)
    command ‘/usr/bin/perl Makefile.PL PREFIX=/tmp/.spamassassin80586kzqcgtmp/ignored INSTALLSITEARCH=/var/lib/spamassassin/compiled/5.020/3.004000 >>/tmp/.spamassassin80586kzqcgtmp/log’ failed: exit 2
    dpkg: error processing package sa-compile (–configure):
    subprocess installed post-installation script returned error exit status 12
    Errors were encountered while processing:
    sa-compile
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    Do you have any ideas how to fix it?

    Thanks

  4. It seems like the packages “dovecot-imapd” and “dovecot-managesieved” aren’t in the default repositories.

  5. It should be noted that if you don’t install Roundcube (opting for no web client or Squirrelmail), you’ll need to otherwise install Apache, PHP and all of the interconnecting packages.

  6. Is there a way to uninstall Roundcube and reinstall it from scratch. Sorry, I am one of those people that has only a little knowledge of Linux but found your tutorial interesting and detailed enough to experiment with running my own server. I had no problems with the installation up to the point of trying to install Roundcube. Thank you.

  7. Robert W.Mills

    Re: Roundcube and Roundcube Plugins

    Both of these packages are in the main raspberrypi.org jessie repository.

  8. Robert W.Mills

    Re: Roundcube and Roundcube Plugins [UPDATE]

    The raspberrypi.org jessie repository contains an older version that does not have the /etc/roundcube/config.inc.php file.

    This file did not appear until version 1.0 when they merged main.inc.php and debian-db.php.

  9. Jim Blaich

    I thank you for the efforts put into this guide. I know you must have, over the years, put in a lot of time to bring it up to this state. I know how time can ravage an online guide though (hehe, I’ve read a lot these past 2 weeks). 🙁 I know people have variations on how they desire the install, and how things change based on distros/distro releases, and that you can’t satisfy everyone.

    I’ve noticed that the guide is starting to show signs of wear and tear. For instance, there are dead links (such as the link for “samples” in the paragraph about chaining certificates.) In the section for installing Jesse, and the subsequent software that you expect to be installed, you actually don’t list Apache in there as a package to install. Later you refer to setting up certificates, and apache virtual hosts, yet no Apache is installed even though we are following the guide. Another is that there’s an error installing roundcube — can’t configure due to something missing which in the end requires you to uninstall and reinstall.

    Also, there are a large number of concepts that result in the reader running into dead-ends. Readers will get stuck on, that is, unless they are already extremely well seasoned administrators. It would be great if you’d actually give more detail on setting this up. Granted you are just providing concepts for us to study about, but when the context is missing the concepts are much harder to understand and apply. So, for me, at least, I would appreciate a bit more detail. It is a guide, after all. Maybe a completed set of .conf files for all relevant programs would be helpful. How did you tell dovecot to use the /var/vmail///Maildir?

    Anyway, this isn’t meant to be a harsh criticism. I’m hoping that you might be willing to take another look in order to correct the errors and add some detail. That would help.

  10. Note that the Roundcube installation depends on the Apache user and group being www-data! If you renamed one of these the install scripts will fail.

  11. Hello Christoph,

    I’m trying to install ISPmail on openSUSE. I have Postfix, MySQL (MariaDB) and Nginx installed. I’ve found almost all the packages you listed here except spamass-milter in openSUSE repositories. I’ve found some RPM packages of spamass-milter here: http://rpm.pbone.net/index.php3?stat=3&search=spamass-milter&srodzaj=3&dist%5B%5D=46 but I’m not sure if they are acceptable (not too old, etc.). And I found an article in Apache wiki about integrating SpamAssassin into Postfix using spamd ( https://wiki.apache.org/spamassassin/IntegratedSpamdInPostfix ). Could you please give me an advice how to “work it around” better. 🙂

  12. Sorry, I forgot to add, I have PHP-FPM, TLS certificates from Let’s Encrypt, phpMyAdmin installed too (I’ve got Nextcloud working on my mini-server).

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top