Postfix: the Definitive Guide by Kyle D
Total Page:16
File Type:pdf, Size:1020Kb
www.it-ebooks.info www.it-ebooks.info Postfix The Definitive Guide www.it-ebooks.info Other networking resources from O’Reilly Related titles sendmail Mac OS X Panther for Unix qmail Geeks sendmail Cookbook Mac OS X Panther in a Programming Internet Email Nutshell Essential System Mac OS X Panther Pocket Administration Guide TCP/IP Network Learning Unix for Mac OS X Administration Panther Running Mac OS X Panther Applescript: The Definitive Guide networking.oreilly.com networking.oreilly.com is a complete catalog of O’Reilly books on networking and related technologies, including sample chapters and code examples. oreillynet.com is the essential portal for developers interested in open and emerging technologies, including new platforms, programming languages, and operating systems. Conferences O’Reilly & Associates brings diverse innovators together to nur- ture the ideas that spark revolutionary industries. We specialize in documenting the latest tools and systems, translating the inno- vator’s knowledge into useful skills for those in the trenches. Visit conferences.oreilly.com for our upcoming events. Safari Bookshelf (safari.oreilly.com) is the premier online refer- ence library for programmers and IT professionals. Conduct searches across more than 1,000 books. Subscribers can zero in on answers to time-critical questions in a matter of seconds. Read the books on your Bookshelf from cover to cover or simply flip to the page you need. Try it today with a free trial. www.it-ebooks.info ,psfx.book.2768 Page iii Thursday, March 24, 2011 1:20 PM Postfix The Definitive Guide Kyle D. Dent Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo www.it-ebooks.info ,psfx.book.2768 Page iv Thursday, March 24, 2011 1:20 PM Postfix: The Definitive Guide by Kyle D. Dent Copyright © 2004 O’Reilly Media, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly Media, Inc. books may be purchased for educational, business, or sales promotional use. On- line editions are also available for most titles (safari.oreilly.com). For more information, contact our cor- porate/institutional sales department: (800) 998-9938 or [email protected]. Editor: Andy Oram Production Editor: Reg Aubry Cover Designer: Ellie Volckhausen Interior Designer: David Futato Printing History: December 2003: First Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Postfix: The Definitive Guide, the image of a dove, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. ISBN: 978-0-596-00212-1 [LSI] [2011-03-25] www.it-ebooks.info Table of Contents Foreword . ix Preface . xi 1. Introduction . 1 Postfix Origins and Philosophy 1 Email and the Internet 3 The Role of Postfix 5 Postfix Security 6 Additional Information and How to Obtain Postfix 8 2. Prerequisites . 10 Unix Topics 10 Email Topics 12 3. Postfix Architecture . 19 Postfix Components 19 How Messages Enter the Postfix System 20 The Postfix Queue 22 Mail Delivery 22 Tracing a Message Through Postfix 25 4. General Configuration and Administration . 28 Starting Postfix the First Time 29 Configuration Files 30 Important Configuration Considerations 41 Administration 44 v www.it-ebooks.info master.cf 47 Receiving Limits 51 Rewriting Addresses 52 chroot 56 Documentation 57 5. Queue Management . 58 How qmgr Works 58 Queue Tools 62 6. Email and DNS . 68 DNS Overview 68 Email Routing 69 Postfix and DNS 72 Common Problems 75 7. Local Delivery and POP/IMAP . 77 Postfix Delivery Transports 77 Message Store Formats 78 Local Delivery 80 POP and IMAP 83 Local Mail Transfer Protocol 84 8. Hosting Multiple Domains . 89 Shared Domains with System Accounts 90 Separate Domains with System Accounts 90 Separate Domains with Virtual Accounts 91 Separate Message Store 95 Delivery to Commands 95 9. Mail Relaying . 103 Backup MX 103 Transport Maps 106 Inbound Mail Gateway 109 Outbound Mail Relay 110 UUCP, Fax, and Other Deliveries 111 vi | Table of Contents www.it-ebooks.info 10. Mailing Lists . 112 Simple Mailing Lists 113 Mailing-List Managers 117 11. Blocking Unsolicited Bulk Email . 125 The Nature of Spam 125 The Problem of Spam 126 Open Relays 127 Spam Detection 127 Anti-Spam Actions 129 Postfix Configuration 130 Client-Detection Rules 131 Strict Syntax Parameters 143 Content-Checking 144 Customized Restriction Classes 147 Postfix Anti-Spam Example 149 12. SASL Authentication . 151 SASL Overview 152 Postfix and SASL 154 Configuring Postfix for SASL 154 Testing Your Authentication Configuration 159 SMTP Client Authentication 162 13. Transport Layer Security . 164 Postfix and TLS 165 TLS Certificates 165 14. Content Filtering . 174 Command-Based Filtering 175 Daemon-Based Filtering 177 Other Considerations 181 15. External Databases . 183 MySQL 184 LDAP 190 Table of Contents | vii www.it-ebooks.info A. Configuration Parameters . 195 B. Postfix Commands . 219 C. Compiling and Installing Postfix . 221 D. Frequently Asked Questions . 234 Index . 239 viii | Table of Contents www.it-ebooks.info Foreword All programmers are optimists—these words of wisdom were written down almost thirty years ago by Frederick P. Brooks, Jr.* The Postfix mail system is a fine example of this. Postfix started as a half-year project while I was visiting the network and security department at IBM Research in New York state. Although half a year was enough time to replace the mail system on my own workstation, it was not nearly enough to build a complete mail system for general use. Throughout the next year, a lot of code was added while the software was tested by a closed group of experts. And in the five years that followed the public release, Postfix more than doubled in size and in the number of features. Meanwhile, active development continues. One of the main goals of Postfix is wide adoption. Building Postfix was only the first challenge on the way to that goal. The second challenge was to make the software accessible. While expert users are happy to Read The Friendly Manual that accompa- nies Postfix, most people need a more gentle approach. Truth be told, I would not expect to see wide adoption of Postfix without a book to introduce the concepts behind the system, and which gives examples of how to get common tasks done. I was happy to leave the writing of this book to Kyle Dent. Just like Postfix, I see this book as a work in progress. In the time that the first edi- tion of the book was written, Postfix went through several major revisions. Some changes were the result of discussions with Kyle in order to make Postfix easier to understand, some changes added functionality that was missing from earlier ver- sions, and some changes were forced upon Postfix by the big bad ugly world of junk email and computer viruses. Besides the changes that introduced new or extended features, many less-visible changes were made behind the scenes as part of ongoing maintenance and improvement. * Frederick P. Brooks, Jr.: The Mythical Man-Month: Essays on Software Engineering, Addison Wesley, 1975. ix This is the Title of the Book, eMatter Edition Copyright © 2007 O’Reillywww.it-ebooks.info & Associates, Inc. All rights reserved. This book describes Postfix Version 2.1, and covers some of the differences with older Postfix versions that were widely used at the time of publication. As Postfix continues to evolve, it will slowly diverge from this book, and eventually this book will have to be updated. While it is a pleasure for me to welcome you to this first edition, I already look forward to an opportunity to meet again in the near future. —Wietse Venema Hawthorne, New York September 19, 2003 x | Foreword This is the Title of the Book, eMatter Edition Copyright © 2007 O’Reillywww.it-ebooks.info & Associates, Inc. All rights reserved. Preface I’m always astounded when I think about the early designers of Internet technolo- gies. They were (and many still are) an amazing group of people who developed soft- ware and technologies for a network that was minuscule, by comparison with today’s Internet. Yet their work scaled and has continued to function in not only a much larger but in a very different environment. The expansion hasn’t been com- pletely without growing pains, but that doesn’t diminish this amazing feat. Sendmail is an example of one of the early technologies that was written for a different uni- verse, yet is still relevant and handles a large portion of email today. Postfix has an advantage in that it was built with an awareness of the scope and hos- tile environment it would have to face. In fact, its creation was motivated by the need to overcome some of the problems of software written in a more innocent age. What a difference a little hindsight can make. I first started using Postfix when I was working with systems in a security-sensitive environment. The promise of more flexibility and better security caught my interest as soon as I heard about it. I was not disappointed. It didn’t take long before I was hooked, and preferred using Postfix everywhere.