O'Reilly logo

qmail by John Levine

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required


Since its release in 1998, qmail has quietly become one of the most widely used applications on the Internet. It’s powerful enough to handle mail for systems with millions of users, including Yahoo Mail and VSNL (the largest ISP in India), while being compact enough to work on even the smallest PC Unix and Linux systems. Its component design makes it easy to extend and customize while keeping its key functions secure.

Qmail’s design is rather different from its best-known predecessor, sendmail. People who are familiar with sendmail often have trouble recasting their problems and solutions in qmail terms. In this book, I try first to help the reader establish a qmail frame of mind, then show how the pieces of qmail work, and finally show how qmail can deal with some more complex mailing tasks such as handling mail for multiple domains, mailing lists, and gateways to other services.

What’s Inside?

This book is organized into two sections, consisting of the following chapters.

Part I: Introduction to Qmail

Chapter 1, provides an overview of Internet email and the terminology used to describe it.

Chapter 2, outlines how qmail works, and gives a description of its basic parts and the philosophy behind its design and use.

Chapter 3, covers the basics of downloading, configuring and installing qmail, and other essential packages.

Chapter 4, finishes the job of configuring and starting qmail.

Chapter 5, addresses issues encountered when converting an existing sendmail system and its configuration files to qmail.

Chapter 6, looks at the issues involved in accepting mail from users on the qmail host and other systems, including cleaning up the sloppily formatted mail that most user mail programs send.

Chapter 7, describes the processing of incoming mail, various tricks to let users identify themselves as local users when roaming away from the local network, and adding cryptographic security to mail transfers.

Chapter 8, covers sorting, reading, and otherwise dealing with local mailboxes.

Chapter 9, covers anti-virus and anti-spam techniques, both those that can be built into qmail and ways to call external filters like Spamassassin.

Part II: Advanced Qmail

Chapter 10, defines the way that qmail delivers mail to local addresses.

Chapter 11, defines the way that qmail delivers mail to remote addresses.

Chapter 12, describes qmail’s simple but powerful abilities to handle domains with their own sets of addresses, including building mail gateways to other services, and special routing for selected mail destinations.

Chapter 13, covers POP and IMAP, the standard ways that users pick up mail from PC mail programs, as well as “POP toasters,” dedicated POP servers with many mailboxes.

Chapter 14, details qmail’s built-in mailing list features, the companion ezmlm mailing list manager, and offers some advice on connecting qmail to other mailing list managers such as mailman and majordomo.

Chapter 15, describes qmail’s built-in database of local mail addresses and subaddresses.

Chapter 16, describes log analysis tools and offers rules of thumb for tuning qmail for best performance.

Chapter 17, covers applications with multiple copies of qmail on one computer, copies of qmail cooperating on many computers, and the mini-qmail package to run a mail hub serving many small client systems.

Chapter 18, shows many problems and solves them.

Style Conventions

This book uses the following typographical conventions:


Indicates the names of files, databases, directories, hostnames, domain names, usernames, email addresses, sendmail feature names, Unix utilities, programs, and it is used to emphasize new terms when they are first introduced.

Constant width

Indicates configuration files, commands and variables, m4 macros and built-in commands, and Unix command-line options. It is used to show the contents of files and the output from commands. Keywords are also in constant width.

Constant width bold

Used in examples to show commands or text that you would type.

Constant width italic

Used in examples and text to show variables for which a context-specific substitution should be made. (The variable filename, for example, would be replaced by some actual filename.)

Examples and Patches

The examples from this book and the author’s source code patches for qmail and related packages are freely downloadable from the author’s web site at:


Comments and Questions

We have verified the information in this book to the best of our ability, but you may find that features have changed (or even that we have made mistakes!). Please let us know about any errors you find, as well as your suggestions for future editions, by writing to:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
(800) 998-9938 (in the United States or Canada)
(707) 829-0515 (international or local)
(707) 829-0104 (fax)

We have a web page for this book, where we list errata, examples, or any additional information. You can access this page at:


To comment or ask technical questions about this book, send email to:

You can sign up for one or more of our mailing lists at:


For more information about our books, conferences, software, Resource Centers, and the O’Reilly Network, see our web site at:


You may also write to the author directly at:


I wish to thank my reviewers, Mark Delany and Russell Nelson, for careful reading of the manuscript and many suggestions to improve it. I particularly thank my editor Simon St.Laurent and the staff at O’Reilly for believing my assurances that this book would in fact be finished, despite mounting evidence to the contrary.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required