Oreilly Sendmail 4Th Edition.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
sendmail Other resources from O’Reilly Related titles sendmail 8.13 Companion DNS & Bind Cookbook™ sendmail Cookbook™ DNS and Bind TCP/IP Network Administration oreilly.com oreilly.com is more than a complete catalog of O’Reilly books. You’ll also find links to news, events, articles, weblogs, sample chapters, and code examples. oreillynet.com is the essential portal for developers interested in open and emerging technologies, including new platforms, pro- gramming languages, and operating systems. Conferences O’Reilly brings diverse innovators together to nurture the ideas that spark revolutionary industries. We specialize in document- ing the latest tools and systems, translating the innovator’s knowledge into useful skills for those in the trenches. Visit con- ferences.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 sim- ply flip to the page you need. Try it today for free. FOURTH EDITION sendmail Bryan Costales, George Jansen, and Claus Aßmann with Gregory Neil Shapiro Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo sendmail, Fourth Edition by Bryan Costales, George Jansen, and Claus Aßmann with Gregory Neil Shapiro Copyright © 2008 Bryan Costales, George Jansen, and Claus Aßmann. 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 books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or [email protected]. Editor: Tatiana Apandi Indexer: John Bickelhaupt Production Editor: Mary Brady Cover Designer: Karen Montgomery Copyeditor: Audrey Doyle Interior Designer: David Futato Proofreader: Colleen Gorman Illustrator: Jessamyn Read Printing History: November 1993: First Edition. January 1997: Second Edition. December 2002: Third Edition. October 2007: Fourth Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. sendmail, the image of a flying fox, 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 authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. ISBN-10: 0-596-51029-2 ISBN-13: 978-0-596-51029-9 [C] To Terry, my wife, without whom this fourth edition would have been impossible. —Bryan Costales Table of Contents Preface . xv 1. Some Basics . 1 1.1 Email Basics 1 1.2 Requests for Comments (RFCs) 2 1.3 Email and sendmail 2 1.4 Basic Parts of sendmail 4 1.5 Basic Parts of a Mail Message 5 1.6 Basic Roles of sendmail 10 1.7 Basic Modes of sendmail 18 1.8 The sendmail.cf File 29 Part I. Administration 2. Download, Build, and Install . 41 2.1 Vendor Versus Compiling 41 2.2 Download the Source 42 2.3 What’s Where in the Source 45 2.4 Build sendmail 53 2.5 Install sendmail 60 2.6 Pitfalls 69 2.7 Build m4 Macro Reference 69 3. Tune sendmail with Compile-Time Macros . 103 3.1 Before You Begin, a Checklist 103 3.2 To Port, Tune, or Debug 105 3.3 Pitfalls 108 3.4 Compile-Time Macro Reference 108 vii 4. Maintain Security with sendmail . 154 4.1 Why root? 154 4.2 The Environment 156 4.3 SMTP Probes 157 4.4 The Configuration File 160 4.5 Permissions 164 4.6 The aliases File 169 4.7 Forged Mail 170 4.8 Security Features 173 4.9 Other Security Information 181 4.10 Pitfalls 182 5. Authentication and Encryption . 183 5.1 Support SMTP AUTH 183 5.2 Public Key Cryptography 199 5.3 STARTTLS 202 5.4 Pitfalls 219 6. The sendmail Command Line . 220 6.1 Alternative argv[0] Names 220 6.2 Command-Line Switches 223 6.3 List of Recipient Addresses 226 6.4 Processing the Command Line 226 6.5 sendmail’s exit( ) Status 228 6.6 Pitfalls 230 6.7 Alphabetized Command-Line Switches 231 7. How to Handle Spam . 251 7.1 The Local_check_ Rule Sets 252 7.2 How DNSBL Works 260 7.3 Check Headers with Rule Sets 265 7.4 Relaying 267 7.5 The access Database 277 7.6 Spam Suppression Features 290 7.7 Pitfalls 297 8. Test Rule Sets with -bt . 299 8.1 Overview 299 8.2 Configuration Lines 301 viii | Table of Contents 8.3 Dump a sendmail Macro or Class 304 8.4 Show an Item 305 8.5 Complex Actions Made Simple 307 8.6 Process-Specified Addresses 314 8.7 Add Debugging for Detail 318 8.8 Batch Rule-Set Testing 319 8.9 Pitfalls 320 9. DNS and sendmail . 321 9.1 Overview 321 9.2 How sendmail Uses DNS 325 9.3 Set Up MX Records 332 9.4 How to Use dig 338 9.5 Pitfalls 343 10. Build and Use Companion Programs . 346 10.1 The Build Script 346 10.2 The editmap Program 354 10.3 The mail.local Delivery Agent 359 10.4 The mailstats Program 364 10.5 The makemap Program 370 10.6 The praliases Program 376 10.7 The rmail Delivery Agent 378 10.8 The smrsh Program 379 10.9 The vacation Program 382 10.10 Pitfalls 393 11. Manage the Queue . 394 11.1 Overview of the Queue 394 11.2 Parts of a Queued Message 396 11.3 Using Multiple Queue Directories 401 11.4 Queue Groups (V8.12 and Later) 408 11.5 Bogus qf Files 419 11.6 Printing the Queue 422 11.7 How the Queue Is Processed 426 11.8 Cause Queues to Be Processed 427 11.9 Process Alternative Queues 436 11.10 Queue Quarantining 438 11.11 Pitfalls 444 11.12 The qf File Internals 445 Table of Contents | ix 12. Maintain Aliases . 460 12.1 The aliases(5) File 460 12.2 Forms of Alias Delivery 465 12.3 Write a Delivery Agent Script 470 12.4 Special Aliases 472 12.5 The aliases Database 478 12.6 Prevent Aliasing with -n 482 12.7 Pitfalls 483 13. Mailing Lists and ~/.forward . 485 13.1 Internal Mailing Lists 485 13.2 :include: Mailing Lists 486 13.3 Defining a Mailing List Owner 490 13.4 Exploder Mailing Lists 491 13.5 Problems with Mailing Lists 492 13.6 Mail List Etiquette 495 13.7 Packages That Help 499 13.8 The User’s ~/.forward File 500 13.9 Pitfalls 506 14. Signals, Transactions, and Syslog . 508 14.1 Signal the Daemon 508 14.2 Log Transactions with -X 512 14.3 Log with syslog 513 14.4 Pitfalls 520 14.5 Other Useful Logging 520 14.6 Alphabetized syslog Equates 521 15. Debug sendmail with -d . 530 15.1 The Syntax of -d 530 15.2 The Behavior of -d 532 15.3 Interpret the Output 533 15.4 The -D Debug File Switch 535 15.5 Table of All -d Categories 536 15.6 Pitfalls 539 15.7 Reference for -d in Numerical Order 540 x | Table of Contents Part II. Configuration Reference 16. Configuration File Overview . 577 16.1 Overall Syntax 578 16.2 Comments 579 16.3 V8 Comments 579 16.4 Continuation Lines 580 16.5 The V Configuration Command 580 16.6 Pitfalls 583 17. Configure sendmail.cf with m4 . 584 17.1 The m4 Preprocessor 584 17.2 Configure with m4 587 17.3 m4 Macros by Function 594 17.4 Masquerading 598 17.5 Relays 602 17.6 UUCP Support 606 17.7 Pitfalls 611 17.8 Configuration File Feature Reference 611 18. The R (Rules) Configuration Command . 648 18.1 Why Rules? 648 18.2 The R Configuration Command 649 18.3 Tokenizing Rules 655 18.4 The Workspace 657 18.5 The Behavior of a Rule 657 18.6 The LHS 659 18.7 The RHS 661 18.8 Pitfalls 671 18.9 Rule Operator Reference 672 19. The S (Rule Sets) Configuration Command . 683 19.1 The S Configuration Command 683 19.2 The Sequence of Rule Sets 689 19.3 The canonify Rule Set 3 690 19.4 The final Rule Set 4 694 19.5 The parse Rule Set 0 696 19.6 The localaddr Rule Set 5 700 Table of Contents | xi 19.7 Rule Sets 1 and 2 702 19.8 Pitfalls 703 19.9 Policy Rule Set Reference 703 20. The M (Mail Delivery Agent) Configuration Command . 711 20.1 The M Configuration Command 711 20.2 The Symbolic Delivery Agent Name 712 20.3 The mc Configuration Syntax 713 20.4 Delivery Agents by Name 716 20.5 Delivery Agent Equates 736 20.6 How a Delivery Agent Is Executed 756 20.7 Pitfalls 758 20.8 Delivery Agent F= Flags 759 21. The D (Define a Macro) Configuration Command . 784 21.1 Preassigned sendmail Macros 785 21.2 Command-Line Definitions 786 21.3 Configuration-File Definitions 787 21.4 Macro Names 790 21.5 Macro Expansion: $ and $& 791 21.6 Macro Conditionals: $?, $|, and $.