The Book of Postfix
Total Page:16
File Type:pdf, Size:1020Kb
THE BOOK OF™ POSTFIX State-of-the-Art Message Transport by Ralf Hildebrandt and Patrick Koetter San Francisco THE BOOK OF POSTFIX. Copyright © 2005 by Ralf Hildebrandt and Patrick Koetter. All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. Printed on recycled paper in the United States of America 1 2 3 4 5 6 7 8 9 10 – 07 06 05 04 No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. The Book of is a trademark of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Publisher: William Pollock Managing Editor: Karol Jurado Production Manager: Susan Berge Cover and Interior Design: Octopod Studios Developmental Editor: Brian Ward Technical Reviewer: Brian Ward Copyeditor: Andy Carroll Compositor: Riley Hoffman Proofreader: Stephanie Provines Indexer: Kevin Broccoli For information on book distributors or translations, please contact No Starch Press, Inc. directly: No Starch Press, Inc. 555 De Haro Street, Suite 250, San Francisco, CA 94107 phone: 415.863.9900; fax: 415.863.9950; [email protected]; http://www.nostarch.com The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it. Library of Congress Cataloging-in-Publication Data Hildebrandt, Ralf. The book of Postfix : state-of-the-art message transport / Ralf Hildebrandt and Patrick Koetter. p. cm. ISBN 1-59327-001-1 1. Postfix (Computer file). 2. Electronic mail systems--Computer programs. 3. Internet. I. Koetter, Patrick. II. Title. TK5105.74.P66H55 2005 005.7'13--dc22 2003017563 No Starch Press, Copyright © 2005 by Ralf Hildebrandt and Patrick Koetter To those who like good software No Starch Press, Copyright © 2005 by Ralf Hildebrandt and Patrick Koetter ABOUT THE AUTHORS Ralf Hildebrandt and Patrick Koetter are active and well-known figures in the Postfix community. Hildebrandt is a manager technics for T-Systems, a German information and communications technology (ICT) solutions company. Koetter is an information architect running his own company consulting and developing corporate communication for customers in Europe and Africa. Both have spoken about Postfix at industry conferences and hacker conventions and contribute regularly to a number of open source mailing lists. No Starch Press, Copyright © 2005 by Ralf Hildebrandt and Patrick Koetter ACKNOWLEDGMENTS There are a lot of people we need to thank for this book, so we’ll each give our lists. Ralf Hildebrandt One thing I noticed while writing this book was how little I knew about how Postfix works “under the hood.” I knew how it behaved, but not exactly why, at least not in every single component and corner-case. In some cases I didn’t know much, in other areas I found my knowledge (or lack thereof) to be wrong. I had to RTFM and ask a lot of questions on the helpful postfix-users mailing list to get the details. This book will not be able to replace the experience of running Postfix for more than five years, but it will lead you closer to mastering it. Admittedly, when I started with Unix in ’94, the Internet was a much safer place than it is now. There wasn’t any spam! I only got to know Postfix because Sendmail kept crashing on me. After a brief interlude with qmail, I found Postfix and stuck with it. I never looked back. When Bill approached me and asked if I wanted to write a book about Postfix, I hesitated at first. I needed a co-author, since the sheer amount of work to be done was far too much for one person. At that time, Patrick was cursing SASL on the list and vowed to write a SASL-HOWTO if he ever got it working. He did, and I read the HOWTO, liked it, and asked him for his co- authorship. As it turns out, the amount of work was too much even for two people, so Brian Ward joined us as a technical editor, adding valuable experience in areas where we lacked it. Without the help of Wietse Venema, Vi(c|k)tor Duchovni, Lutz Jänicke, Andreas Winkelmann, and Peter Bieringer, this book would have never reached its present state, so they’re in for a free copy. Not that they need it, but it sure makes a great gift. A big thanks and love go to my wife Constanze No Starch Press, Copyright © 2005 by Ralf Hildebrandt and Patrick Koetter who endured my frequent “But I still have to write a chapter now!” excuses and thus made it possible to finish the book instead of letting it become vaporware. Oh yeah, and when reading Patrick’s comments, please keep in mind that I’m only slightly crazy. Patrick Koetter Years will pass before the Internet provides us with all the services we want it to have. Just as with any other new medium, the immediate impulse of those who provide services is to push growth, especially in the quantity of content and services. The quality of the service and its functionalities usually has to stand back—at least until the service starts to pay off. In the meantime it is exposed to people who like to abuse and destroy things rather than promote and expand them. This has happened to email and this is where Postfix comes in, and really does provide a new dimension of quality. When I went out to get myself an SMTP server, I was shocked that Sendmail seemed to require a diploma of some sort, especially to figure out the macros. So I looked around for other software. To cut it short: I fell in love with Postfix. Postfix showed me that it’s possible to have complex software configured with a simple, clear, and structured syntax. If you know SMTP, you already know most of the important details of configuring Postfix. I didn’t really know SMTP when Ralf asked me to write the book with him. This book required me to learn more than I had expected and to correct misunderstandings. I am very proud that this book gives me the opportunity to hand over what I know about computers and email today. Hopefully this book will get you well on your way to using Postfix creatively. Creativity grows the best when there is knowledge. This book would not have seen the light without the knowledge, curiosity, and support of Wietse Venema, Vi(c|k)tor Duchovni, Liviu Daia, Lutz Jänicke, Florian Kirstein, Walter Steinsdorfer, Roland Rollinger, Tom Thomas, Alexey Melnikov, Andreas Winkelmann, Eric “cybertime hostmaster,” and the users of the Postfix mailing list; their questions and problems told us what was missing when we thought everything had been said. Most importantly, I need to thank Ralf, whose knowledge about Postfix is outclassed only by his sassy use of computers. He’s like a duck taking to water in this respect. It was Ralf who chose me to be his companion on this adven- ture called The Book of Postfix, and I’m indebted to this crazy guy who became a close friend as we wrote this book. The book has been a great challenge, not only to me, but also to my wife Birgit; her trust in me carried me through the countless lines of this book. It’s a great privilege to be asked to do something that you’ve set your heart on. It’s a godsend to have somebody like Birgit at your side when you finally do it. viii Acknowledgments No Starch Press, Copyright © 2005 by Ralf Hildebrandt and Patrick Koetter BRIEF CONTENTS About This Book Chapter 5 xxv Anatomy of Postfix 35 Chapter 1 An Introduction to Postfix Part II: Content Control 1 Chapter 6 Part I: Basics A Postmaster’s Primer to Email 55 Chapter 2 Preparing Your Host and Chapter 7 Environment How Message Transfer 7 Restrictions Work 69 Chapter 3 Mail Server for a Single Domain Chapter 8 17 Using Message Transfer Restrictions Chapter 4 81 Dial-up Mail Server for a Single Domain Chapter 9 29 How Built-in Content Filters Work 111 No Starch Press, Copyright © 2005 by Ralf Hildebrandt and Patrick Koetter Chapter 10 Chapter 16 Using Built-in Content Filters SMTP Authentication 117 247 Chapter 11 Chapter 17 How External Content Understanding Filters Work Transport Layer Security 129 267 Chapter 12 Chapter 18 Using External Content Filters Using Transport Layer Security 141 279 Chapter 19 Part III: Advanced A Company Mail Server Configurations 313 Chapter 13 Mail Gateways Chapter 20 169 Running Postfix in a chroot Environment 369 Chapter 14 A Mail Server for Multiple Domains Part IV: Tuning Postfix 189 Chapter 21 Chapter 15 Remote Client Concurrency Understanding SMTP and Request Rate Limiting Authentication 379 217 Chapter 22 Performance Tuning 387 x Brief Contents No Starch Press, Copyright © 2005 by Ralf Hildebrandt and Patrick Koetter Appendices Appendix C CIDR and SMTP Standards Appendix A Reference Installing Postfix 435 407 Glossary Appendix B 441 Troubleshooting Postfix 419 Index 449 Brief Contents xi No Starch Press, Copyright © 2005 by Ralf Hildebrandt and Patrick Koetter No Starch Press, Copyright © 2005 by Ralf Hildebrandt and Patrick Koetter CONTENTS IN DETAIL ABOUT THIS BOOK xxv Additional Resources .............................................................................................xxvi Postfix Documentation, How-tos, and FAQs .................................................xxvi Mailing Lists ............................................................................................xxvi Conventions Used in This Book ..............................................................................xxvii Domains and Names Used in This Book .................................................................