Qmail Installation Guide
Total Page:16
File Type:pdf, Size:1020Kb
qmail installation guide Mark Pustjens The Mindlab Hosting 3rd September 2004 qmail installation guide an extensive guide to setup a complete qmail based MDA Mark Pustjens 3rd September 2004 List of adresses Mark Pustjens C. de Houtmanstraat 18 6045 HP Roermond 06-50412316 email: [email protected] The Mindlab Hosting Mestreech 1234 ab I Preamble This guide will describe howto install a qmail based email server, com- plete with virtual domains, pop3, imap, spamassasin and mailinglist (for now). You should be able to use this guide with OpenBSD, FreeBSD and Redhat Linux. II Contents List of Tables VII 1 TODO 1 2 Preparations 2 2.1 Conventions . 2 2.2 Hardware requirements . 2 2.3 Software requirements . 2 2.3.1 Linux . 3 2.3.2 OpenBSD . 3 2.4 Software you need . 3 2.4.1 qmail 1.03 . 3 2.4.2 ucspi-tcp 0.88 . 4 2.4.3 ucspi-ssl 0.68 . 4 2.4.4 daemontools 0.76 . 4 2.4.5 vpopmail 5.4.5 . 4 2.4.6 Courier-IMAP 3.0.7 . 4 2.4.7 Procmail 3.22 . 5 2.4.8 Spamassassin 3.00 . 5 3 Installing the core packages: qmail, ucspi-tcp and daemon- tools 6 3.1 Obtaining the source . 6 3.2 Installing ucspi-tcp . 6 3.2.1 Compiling . 6 3.3 Installing daemontools . 7 3.3.1 Compiling . 7 3.3.2 Installing . 8 3.4 Some notes on daemontools . 10 3.4.1 supervise . 10 3.4.2 softlimit . 10 3.4.3 svc . 11 3.5 Compiling and Installing qmail . 11 III 3.5.1 Compiling . 11 3.5.2 Installing . 12 3.6 Replacing the old MTA . 17 3.7 Testing what we have . 18 3.7.1 Checking the daemons . 18 3.7.2 Sending test messages . 19 3.8 Conclusion . 24 4 Adding services 25 4.1 Overview . 25 4.2 Vpopmail . 25 4.2.1 Compiling and installing vpopmail . 25 4.2.2 Configuring vpopmail . 27 4.2.3 Testing vpopmail . 28 4.2.4 Creating the localhost as virtual domain . 28 4.3 Pop3 . 29 4.3.1 Service scripts . 29 4.3.2 Testing the pop3 server . 29 4.4 IMAP . 30 4.4.1 Compiling Courier-IMAP . 30 4.4.2 Configuring Courier-IMAP . 32 4.5 Conclusion . 34 5 Securing services 35 5.1 Overview . 35 5.2 Certificates . 35 5.3 Installing ucspi-ssl . 36 5.3.1 Compiling . 36 5.3.2 Installing . 37 5.4 Securing SMTP . 37 5.4.1 Receiving messages, qmail-smtpd . 37 5.4.2 Sending messages, qmail-remote . 43 5.5 Securing Pop3 . 44 5.5.1 Configuring POP3 over SSL . 44 5.5.2 Testing POP3 over SSL . 44 5.6 Securing IMAP . 45 5.6.1 Configuring IMAP over SSL . 45 5.6.2 Testing IMAP over SSL . 45 5.7 Conclusion . 46 6 Mail Filtering 47 6.1 Procmail . 47 6.1.1 Installing . 47 6.1.2 Global Filter . 48 IV 6.1.3 Testing the filter . 49 6.2 Basic Spamassassin Filter . 50 6.2.1 Installing . 51 6.2.2 configuring spamd . 53 6.2.3 Adding spamc to the mail delivery process . 55 6.2.4 Testing Spamassassin . 55 6.3 Conclusion . 56 Bibliography I A OpenBSD fstab II B svscanboot III C /var/qmail/rc IV D /var/qmail/bin/qmailctl V E qmail service scripts, qmail-smtpd and qmail-send XII E.1 /var/qmail/supervise/qmail-send/run . XII E.2 /var/qmail/supervise/qmail-send/log/run . XII E.3 /var/qmail/supervise/qmail-smtpd/run . XII E.4 /var/qmail/supervise/qmail-smtpd/log/run . XIII F vpopmail.mysql XIV G vlimits.default XV H qmail service scripts, qmail-pop3d XVII H.1 /var/qmail/supervise/qmail-pop3d/run . XVII H.2 /var/qmail/supervise/qmail-pop3d/log/run . XVII I qmail service scripts, courier-imapd XVIII I.1 /var/courier-imap/supervise/courier-imapd/run . XVIII I.2 /var/courier-imap/supervise/courier-imapd/log/run . XVIII J SMTP AUTH Extension example XIX K qmail service scripts, qmail-smtpsd XXI K.1 /var/qmail/supervise/qmail-smtpsd/run . XXI K.2 /var/qmail/supervise/qmail-smtpsd/log/run . XXI L qmail service scripts, qmail-pop3sd XXII L.1 /var/qmail/supervise/qmail-pop3sd/run . XXII L.2 /var/qmail/supervise/qmail-pop3sd/log/run . XXII V M qmail service scripts, courier-imapsd XXIII M.1 /var/courier-imap/supervise/courier-imapsd/run . XXIII M.2 /var/courier-imap/supervise/courier-imapsd/log/run . XXIII N mail filter scripts XXIV N.1 procmailrc . XXIV N.2 qmail-users . XXVI N.3 qmail-procmail . XXVI O spamassassin service script, spamd XXVII O.1 /var/spamassassin/supervice/spamd/run . XXVII O.2 /var/spamassassin/supervice/spamd/log/run . XXVIII P Installing DBD::mysql using CPAN XXIX Q Spamassassin configuration file XXX R spamassassin procmail recipe XXXIII VI List of Tables 3.1 qmail groups . 12 3.2 qmail users . 13 VII Chapter 1 TODO This is a list of TODO items. You’ll also find TODO items throughout this manual. • qmail-smtpd: tcpserver realblacklist? rblsmtpd (ucspi-tcp). dit moet aan want skip rbl checks in spamassassin staat uit • /var/qmail/queue on seperate filesystem with small blocksize and no softupdates • max DATABYTES to limit email size, man qmail-smtpd • systeem aliassen naar mailinglist sturen. • qmail linken met lib syncdir, of patchen met de fsync patch, qmail wordt veiliger op een fs met soft updates. • script maken om logs makkelijk te bekijken • !!! qmail-maildir++ patch !!! • qmail-remote in ssl wrappen mbv script. als geen ssl beschikbaar is automatische fallback naar gewoon smtp • STARTTLS hoeft niet gebruikt te worden als smtp ook in ssl gewrapped word, dit is dubbelop • vermelden de de source bewaard MOET blijven na het installeren. • tcpserver-mysql patch gebruiken? hiermee kunnen de access databases in mysql gezet worden. Of alleen de access db voor smtpd? • andere database naam voor alle tabellen • qqtool voor queue management. 1 Chapter 2 Preparations 2.1 Conventions Do to the nature of what we are about to do, you should use extreme care with any command you use. Also, in this document we assume you will be using a test server, this reduces any risk to zero if you make any mistake. 2.2 Hardware requirements Qmail is able to run on almost all kinds of hardware, provided a UNIX OS runs on it. 2.3 Software requirements Your system must meet the following requirements. • Qmail is designed to run on any Unix or Unix-like operating system. Qmail’s licence requires it to distributed in source format which means you need a standard C compiler. • Storage space is no longer a problem on modern systems. You’ll need at least 30 to 40 Megabytes of space for the sources and just a little more for building the sources. • A running mySQL server. Although this is not needed for qmail itself, the IMAP server and virtual domains support package we will install do need this. • To be able to use the security features you need an openssl compatible SSL library. Although not necessairy, the following is recommended. 2 CHAPTER 2. PREPARATIONS 3 • Qmail was designed for highly connected systems. Although there are solutions for systems with low availability of an internet connection, a stable connection is recommended. • The filesystem should perform link() calls synchronously. This will prevent loss of email on a system failure, as all data is immidiately written to the disk without delay. • I possible, a seperate filesystem for qmail’s queue and mailstore. This filesystem should be equiped with a small blocksize1. This filesystem should also have a large amount of inodes, increasing the amount of files which can be stored on the filesystem. 2.3.1 Linux If you are using a seperate filesystem for the queue and mailstore, you can speed up disk access a bit by using the following mount options for that filesystem: • noatime; do not update access times. • sync; no caching, this not needed with the syncdir library, reduces performance 2.3.2 OpenBSD If you are planning to install qmail on a system running OpenBSD 3.2 and higher, you need to disable the “nosuid” mount option for the filesystem on which qmail will reside. You can remove this option by editing /etc/fstab. An example is provided in appendix A. 2.4 Software you need The following software packages are used in this guide. 2.4.1 qmail 1.03 Qmail is the set of applications which together make up the mail server. Besides the main qmail package we will need some patches to extend and fix various parts of qmail. • qmail-queue patch • sendmail -f flag patch 1Email files are typically very small. With a small blocksize less space is wasted. CHAPTER 2. PREPARATIONS 4 • qmail 0.0.0.0 patch • qmail-local patch • qmail glibc errno patch • qmail identity = netqmail patch • qmail 64bit compatibility patch • qmail-smtpd patch • qmail AUTH and STARTTLS patch Most of those patches are distributed together with qmail in the netqmail distribution[2]. The instructions in this manual are based on the netqmail distribution. 2.4.2 ucspi-tcp 0.88 This package contains serveral utilities to modularize a tcp server/client environment. 2.4.3 ucspi-ssl 0.68 This package contains SSL enabled versions of the programs in the ucspi-tcp package. We will use those programs to setup SSL wrapped version of the services. 2.4.4 daemontools 0.76 Daemontools is a set of applications to manage services, or daemons.