Guide updated on 29th of February 2016

Debian packages install

Install Daemontools and ucspi-tcp

aptitude install ucspi-tcp daemontools daemontools-run

Install Courier packages

aptitude install courier-base courier-authdaemon courier-authlib courier-authlib-mysql courier-imap courier-imap-ssl courier-pop-ssl courier-pop courierpassd courier-maildrop gamin libgamin0

You should accept all the default answers

Install needed compiler, tools and library

aptitude install cpp g++ gcc make automake wget telnet libtool patch patchutils logrotate dh-make-perl libltdl7 libcdb1 sudo equivs expect openssl libssl-dev libgmp3-dev libgdbm-dev libpcre++-dev libpcre-ocaml libpcre-ocaml-dev makepasswd

For security reason, it's a good idea to remove the compilers (cpp, g++, gcc and make) after your complete this guide

Install MySQL database and libraries

aptitude install mysql-common mysql-server-5.5 mysql-client-5.5 mysql-server-core-5.5 libmysqlclient18 libmysqlclient-dev

Remember your root MySQL password (described as MySQL_root_password later in this guide)

Install Apache & PHP

aptitude install apache2 apache2-mpm-prefork php5 php5-common libapache2-mod-php5 php5-mysql php5-mcrypt php5-intl

Install antispam and antivirus

aptitude install spamassassin spamc pyzor razor clamav clamav-freshclam clamav-daemon clamav-docs

Install un-archiver tools

aptitude install arj unrar lhasa unzip bzip2 tar tnef

Install perl modules

aptitude install spf-tools-perl libmailtools-perl libnet-cidr-lite-perl libnet-daemon-perl libtest-distribution-perl libmail-spf-perl libperl-dev

aptitude install libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl perl-doc libgeo-ip-perl libdate-manip-perl libio-string-perl libio-socket-ssl-perl libnet-ident-perl libsys-syslog-perl libencode-detect-perl

aptitude install libnet-dns-perl libtimedate-perl libio-compress-perl libdigest-hmac-perl libdigest-sha-perl libparse-syslog-perl libmail-dkim-perl libcrypt-openssl-bignum-perl

Install debug / manipulation tools

Those last ones are not mandatory but are useful if you need to debug

aptitude install dnsutils whois findutils pciutils less net-tools tcpdump iptraf lsof dstat iotop htop mc locate

Download all the needed items for the Qmail installation

Users comments
Ramiro - 03/05/2019 21:58

Hello, my english is not good but here we go! 

I'm following this guide for debian 9 (stretch). At the first try if i executed qmail-rspawn as a result i had segmentation fault, which caused that the server could not send or receive emails. 

For this error, i had to add #include "alloc.h"in the file /usr/src/qmail/qmail-1.03/spawn.c. With this patch, everything works fine!




Zinkro - 17/10/2018 20:15

for debian 9 (stretch) use

apt install mariadb-common mariadb-server mariadb-client mariadb-server-core-10.1 libmariadbclient-dev lib

Zinkro - 17/10/2018 19:39

courierpassd is available on jessie packages,


and install with dpkg -i,  no problems.

Testuser - 02/12/2017 06:40

Debian9 error Couldn't find any package whose name or description matched "courierpassd"

Mobin - 18/05/2017 09:06

Hi Thibs


Thanks for your contribution.


Please update this script.


Best Regards,


Daniel - 03/05/2017 21:21

@Mark, I've found unrar on non-free source list for debian 8. Today, I found at multiverse for ubuntu.

Mark neidorff - 17/04/2017 22:41

I'm following this guide now, and unrar is not available.  I'll have to look for it.

Thibs - 15/01/2013 16:30

@Mark : Patch the Debian source package ( just to be sure you keep exactly the same version with the same path

Mark - 03/01/2013 15:57

If I recompile tcpserver (ucspi-tcp) with fefe's patch to support ipv6, is there any other things I should take into account?

Goofy - 25/07/2010 22:39

If you're installing on LUCID, check for installing libmd5-perl. (post #4)

Color Coded Qmail Installation Key
  Regular Black Text     Qmail installation notes and summaries by the author.
  Bold Black Text     Commands to be run by you, the installer.
  Bold/Regular Red Text    Vital and/or critical information.
  Regular Blue text     Denotes helpful tips and hints or hyperlinks.
  Regular Orange Text     Command line output.
  Bold/Regular green text     Denotes the contents of a file or script.