Tải bản đầy đủ (.pdf) (1,310 trang)

Tài liệu sendmail, 4th Edition doc

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (7.16 MB, 1,310 trang )

sendmail
Other resources from O’Reilly
Related titles
sendmail 8.13 Companion
sendmail Cookbook

TCP/IP Network
Administration
DNS & Bind Cookbook

DNS and Bind
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.


sendmail
FOURTH EDITION
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
Editor:
Tatiana Apandi

Production Editor:
Mary Brady
Copyeditor:
Audrey Doyle
Proofreader:
Colleen Gorman
Indexer:
John Bickelhaupt
Cover Designer:
Karen Montgomery
Interior Designer:
David Futato
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
vii
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
viii | Table of Contents
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
Table of Contents | ix
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
x | Table of Contents
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
Table of Contents | xi
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
xii | Table of Contents
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 $. 794
21.7 Macros with mc Configuration 796
21.8 Pitfalls 798

21.9 Alphabetized sendmail Macros 798
22. The C and F (Class Macro) Configuration Commands
. . . . . . . . . . . . . . . . . . .
854
22.1 Class Configuration Commands 854
22.2 Access Classes in Rules 863
22.3 Classes with mc Configuration 866
22.4 Internal Class Macros 868
22.5 Pitfalls 869
22.6 Alphabetized Class Macros 870
23. The K (Database-Map) Configuration Command
. . . . . . . . . . . . . . . . . . . . . .
878
23.1 Enable at Compile Time 879
23.2 The K Configuration Command 882
23.3 The K Command Switches 884
23.4 Use $( and $) in Rules 892
23.5 Database Maps with mc Configuration 896
Table of Contents | xiii
23.6 Pitfalls 897
23.7 Alphabetized Database-Map Types 898
24. The O (Options) Configuration Command
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
947
24.1 Overview 948
24.2 Command-Line Options 948
24.3 Configuration File Options 952
24.4 Options in the mc File 953
24.5 Alphabetical Table of All Options 959
24.6 Option Argument Types 963

24.7 Interrelating Options 965
24.8 Pitfalls 970
24.9 Alphabetized Options 970
25. The H (Headers) Configuration Command
. . . . . . . . . . . . . . . . . . . . . . . . . . .
1120
25.1 Overview 1120
25.2 Header Names 1121
25.3 Header Field Contents 1123
25.4 ?flags? in Header Definitions 1126
25.5 Rules Check Header Contents 1130
25.6 Header Behavior in conf.c 1138
25.7 Headers and mc Configuration 1143
25.8 Headers by Category 1143
25.9 Forwarding with Re-Sent Headers 1147
25.10 Precedence 1148
25.11 Pitfalls 1150
25.12 Alphabetized Header Reference 1150
26. The X (Milters) Configuration Command
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
1169
26.1 Create Milter Support 1170
26.2 Add Configuration Support 1173
26.3 Build a Milter 1181
26.4 Pitfalls 1183
26.5 smfi_ Routine Reference 1183
26.6 xxfi_ Routine Reference 1203
xiv | Table of Contents
Part III. Appendixes
A. The mc Configuration Macros and Directives

. . . . . . . . . . . . . . . . . . . . . . . .
1227
B. What’s New Since Edition 3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1239
C. The checkcompat( ) Function
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1248
Bibliography
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1253
Index
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1255
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
xv
Preface
Changes Since the Previous Edition
The primary reason for this book, the fourth edition of sendmail, is the release of ver-
sion 8.14 of the sendmail program. Since the release of the third edition, V8.13 and
V8.14 sendmail have been released. Each sendmail release has shown marked
improvements over earlier releases and, together, they call for a full update of this
book.
In addition to folding the new V8.14 information into this book, we have fixed all
the errata in the third edition to make this fourth edition much more accurate.
This edition of the sendmail book assumes you are using V8.14, the current version
of the sendmail program. It follows the same general format as earlier editions, but
we realize this might not be the most convenient arrangement for readers who are
primarily interested in what has changed since the last edition. To help minimize this

problem, we have added Appendix B, in which the many improvements of the inter-
vening versions of sendmail are categorized by chapter, complete with references to
the appropriate sections within this book.
Why This Book Is Necessary
King Gordius of Phrygia once created a knot so tangled that no one could undo it.
The Gordian knot stayed tangled, or so the story goes, until Alexander the Great
came along and took a different approach to untying the knot. With a sweep of his
sword, he parted the great knot once and for all.
It would be nice if the knot that is sendmail could be undone with one quick stroke
of fresh insight, but alas, it cannot. Instead, a more mundane approach must be
taken, so in this book we untie the hard way, one strand at a time.
But, you might ask, “Why the effort? Doesn’t sendmail predate the dawn of comput-
ing time? Hasn’t the time come to replace sendmail with something new, something
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
xvi
|
Preface
better, something modern?” Not so. Age has brought sendmail maturity and reliabil-
ity. The sendmail program has withstood the test of time because it is more than just
a program, it is a philosophy: a general-purpose, internetwork mail-routing facility
with the flexibility and configurability to solve the mail-routing needs of all sites
large or small, complex or simple.
These strengths of sendmail are also its weaknesses. Configurability has bred com-
plexity. The sendmail program is difficult to configure and even more difficult to
understand. Its configuration file, for example, can be positively frightening. But
don’t despair. With this book in hand, you should be able to configure sendmail to
meet any need and bring the days of the sendmail guru to an end.
History
The sendmail program was originally written by Eric Allman while he was a student

and staff member at the University of California at Berkeley. At the time, one cam-
pus machine (Ingres) was connected to the ARPAnet and was home to the INGRES
project where Eric was working. Another machine (Ernie CoVax) was home to the
Berkeley Unix project and had recently started using the Unix to Unix Communica-
tion Protocol (UUCP). These machines (as well as several others on campus) were
connected via a low-cost network built by Eric Schmidt, called BerkNet. Software
existed to move mail within ARPAnet, within UUCP, and within BerkNet, but none
yet existed to move mail between these three networks.
A sudden increase in protocol types, coupled with the anticipation of an explosion in
the number of networks, motivated Eric Allman to write delivermail—the precursor
to sendmail.Thedelivermail program was shipped in 1979 with 4.0 and 4.1 BSD
Unix. Unfortunately, delivermail was not flexible enough to handle the changes in
mail-routing requirements that actually occurred. Perhaps its greatest weakness was
that its configuration was compiled in.
In 1980, ARPAnet began converting from Network Control Protocol (NCP) to
Transmission Control Protocol (TCP). This change increased the number of possi-
ble hosts from 256 to more than 1 billion. Another change converted from a “flat”
hostname space (such as MIT-XX) into a hierarchical namespace (such as
XX.MIT.EDU). Prior to these changes, mail was transported using the File Transfer
Protocol (FTP). Afterward, a new protocol was developed for transporting mail,
called Simple Mail Transfer Protocol (SMTP). These developments were not instan-
taneous. Some networks continued to run NCP years after most others switched to
TCP. And SMTP underwent many revisions before finally settling into its present
form.
Responding to these and other changes, Eric evolved delivermail into sendmail.To
ensure that messages transferred between networks would obey the conventions
required by those networks, Eric took a “liberal” approach—modifying address
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Preface

|
xvii
information to conform rather than rejecting it. At the time, for example, UUCP mail
often had no headers, so sendmail had to create them from scratch.
The first sendmail program was shipped with 4.1c BSD (the first version of Berkeley
Unix to include TCP/IP). From that first release to the present,
*
Eric has continued to
enhance sendmail, first at UC Berkeley, then at Britton Lee, then back at UC Berke-
ley, then with InReference Inc., and now with Sendmail, Inc. The current major ver-
sion of sendmail is V8, a major rewrite that includes many bug fixes and significant
enhancements.
But Eric wasn’t the only one working on sendmail. In 1987, Lennart Lovstrand of the
University of Linköping, Sweden, developed the IDA enhancements to BSD sendmail
Version 5. IDA (which stands for Institutionen för Datavetenskap) injected a num-
ber of improvements into sendmail (such as support for .dbm files and separate
rewriting of headers and envelopes) and fixed a number of bugs. As the 1990s
approached, two offspring of IDA appeared.
Neil Rickert (Northern Illinois University) and Paul Pomes (The University of Illi-
nois) took over maintenance of IDA sendmail. With contributions from around the
world, their version (UIUC IDA) represents a continuation of the work begun by
Lennart Lovstrand. Neil focused on fixing and enhancing the configuration files into
their current m4-based form. Paul maintained the code, continually adding enhance-
ments and fixing bugs. In general, their version was large, ambitious, and highly por-
table. It succeeded in solving many complex mail-routing problems.
A variation on IDA sendmail was also developed by Paul Vixie (while at Digital
Equipment Corporation). Called KJS (for King James sendmail), it was a more con-
servative outgrowth of Lennart Lovstrand’s last IDA release. The focus of KJS was on
code improvement rather than changes to configuration files.
In addition to these major offshoots, many vendors modified sendmail to suit their

needs. Sun Microsystems made many modifications and enhancements to sendmail,
including support for nis and nisplus maps. Hewlett-Packard also contributed many
fine enhancements, including
8BITMIME support.
This explosion of sendmail versions led to a great deal of confusion. Solutions to
problems that work for one version of sendmail failed miserably for another. Even
worse, configuration files were not portable, and some features could not be shared.
In 1992, Eric started creating a new version of sendmail to merge all the earlier ver-
sions. V8 officially adopted most of the good features from IDA, KJS, Sun, and HP’s
sendmail, and kept abreast of the latest standards from the Internet Engineering Task
Force (IETF). In 1996, Eric began work on V8.8 sendmail. This release continued the
* With one long gap between 1982 and 1990.
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
xviii
|
Preface
trend begun with V8.7, adding many requested new features and options, and tight-
ening security. In 1998, V8.9 was released, continuing the direction started by V8.8.
In 1999, Sendmail, Inc., was founded in Emeryville, California. Sendmail, Inc., took
over maintenance and development of the open source version of sendmail, and
began work on a commercial version. Sendmail, Inc., has the web site:

and is also one of the sponsors of the open source sendmail’s web site:

For more information on the open source community and the Open Source Initia-
tive (OSI), go to:

The first major offering from Sendmail, Inc., was V8.10 sendmail, released in 2000. It
was mentored by Eric Allman, but largely written by Greg Shapiro.

V8.10 and V8.11 were developed in parallel. Claus Aßmann added SMTP AUTH
and STARTTLS to V8.10, as well as a number of security changes, bringing that ver-
sion up to V8.11. V8.11 was released as a commercial version because of export
restrictions. Shortly afterward, export restrictions were relaxed and V8.11 was
released in open source form.
Claus Aßmann took sendmail in a somewhat new direction with V8.12, in which he
added a suite of new features. V8.13 expanded the Milter interface and added sev-
eral new ways to suppress mail abuse, such as email address harvesting and denial of
service. V8.14 continued this trend by further expanding the Milter interface, adding
more antispam features, and creating more configuration flexibility.
Thoughts from Eric Allman
I have to admit that I’m surprised by how well sendmail has succeeded. It’s not
because of a large marketing organization or a deep-pockets budget. I think there are
three reasons.
First, sendmail took the approach that it should try to accept, clean up, and deliver
even very “crufty” messages instead of rejecting them because they didn’t meet some
protocol. I felt this was important because I was trying to gateway UUCP to the
ARPAnet. At the time, the ARPAnet was small, UUCP was anarchy, and Unix mail
programs generally didn’t even understand headers. It was harder to do, but after all,
the goal was to communicate, not to be pedantic.
Second, I limited myself to the routing function—I wouldn’t write user agents or
delivery backends. This was a departure from the dominant thought of the time, in
which routing logic, local delivery, and often the network code were incorporated
directly into the user agents. But it did let people incorporate their new networks
quickly.
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Preface
|
xix

Third, the sendmail configuration file was flexible enough to adapt to a rapidly
changing world: the 1980s saw the proliferation of new protocols, networks, and
user agents.
And, of course, it didn’t hurt that it was free, available at the right time, and did
what needed to be done.
Configuring sendmail is complex because the world is complex. It is dynamic
because the world is dynamic. Someday sendmail, like X11, will die—but I’m not
holding my breath. In the meantime, perhaps this book will help.
When I started reviewing Bryan’s first-edition manuscript, I had been avoiding any
major work on sendmail. But then I started reading about various petty bugs and
annoyances that all seemed easy to fix. So I started making small fixes, then larger
ones; then I went through RFC1123 to bring the specs up-to-date, cleaned up a
bunch of 8-bit problems, and added ESMTP. It would be fair to say that the first
book and sendmail Version 8 fed on each other—each improving the other.
Organization
We’ve divided this book into an introduction and two parts, each part addressing a
particular aspect of sendmail.
Chapter 1, Some Basics, will be of special help to the new user. It covers the basic
concepts underlying mail delivery and the roles sendmail plays in that delivery.
Part I, Administration, covers all aspects of handling sendmail, from downloading
and installing new releases to managing mailing lists and aliases.
Part II, Configuration Reference, contains a heavily cross-referenced guide for config-
uring and tuning sendmail.
Part III, Appendixes, contains topic not directly germane to any particular chapter.
Audience and Assumptions
This book is primarily intended for system administrators who also administer email.
But not all Unix systems are managed by administrators. Many are managed by pro-
grammers, network engineers, and even inexperienced users. It is our hope that this
book satisfies all of you, no matter what your level of experience.
The true beginner should begin with Chapter 1, skipping ahead as needed.

The beginning system administrator should probably start with Part I to learn how to
build, install, and administer sendmail, then skip ahead to topics of interest.
The experienced system administrator who wants to install and manage V8 sendmail
should read Part I first to gain the needed background. Then explore Part II to dis-
cover further topics of interest.
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
xx
|
Preface
Unix gurus and sendmail specialists should find Part II to be of value (even Eric keeps
a copy on his desk). In it, every arcane detail of sendmail is listed alphabetically. For
example, in Part II you’ll find a single chapter dedicated to options, with every
option listed and explained.
No matter what your level of expertise, the sheer size of this book forces us to
assume that you are familiar with the day-to-day system workings of Unix. If you
aren’t, you must learn Unix elsewhere.
Unix and sendmail Versions
For the most part, we illustrate sendmail under BSD Unix and its variants (such as
FreeBSD). Where AT&T System V (SysV) differs (such as Sun’s Solaris 2.x and
Linux) we illustrate those differences.
Our primary focus throughout this book is on V8.14 sendmail. For completeness,
and where necessary, we also discuss V8.13 and earlier (such as BSD’s version 5,
*
IDA, early Sun, Ultrix, and NeXT) but do not cover them in detail in this edition.
Conventions Used in This Book
The following typographic conventions are used in this book:
Italic
Used for names, including pathnames, filenames, program and command
names, usernames, hostnames, machine names, and mailing-list names, as well

as for mail addresses. It also is used to indicate that part of a program’s output is
not specific. For example, “
error: number or file” indicates that the error will be
shown either as a number or as a filename. Italic is also used to emphasize new
terms and concepts when they are introduced.
Constant Width
Used in examples to show the contents of files or the output from commands.
This includes examples from the configuration file or other files such as message
files, shell scripts, or C-language program source. Constant-width text is quoted
only when necessary to show enclosed space; for example, the five-character

From ” header.
Single characters, symbolic expressions, and command-line switches are always
shown in constant-width font. For instance, the
o option illustrates a single char-
acter, the rule
$- illustrates a symbolic expression, and -d illustrates a command-
line switch.
* The versions jump from 5 to 8 because the managers of the BSD 4.4 Unix distribution wanted all software
to be released as version 8. Prior to that decision, the new BSD sendmail was designated Version 6. V6 sur-
vived only the alpha and beta releases before being bumped to V8.
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Preface
|
xxi
Constant Bold
Used in examples to show commands or some other text that is to be typed liter-
ally by the user. For example, the phrase
cat /var/run/sendmail.pid means the

user should type “cat /var/run/sendmail.pid” exactly as it appears in the text or
example.
Constant Italic
Used in examples to show variables for which a context-specific substitution
should be or will be made. In the string
Snum, for example, num will be a user-
assigned integer.
% Indicates a user shell.
# Indicates a root shell.
Using Code Examples
This book is here to help you get your job done. In general, you may use the code in
this book in your programs and documentation. You do not need to contact us for
permission unless you’re reproducing a significant portion of the code. For example,
writing a program that uses several chunks of code from this book does not require
permission. Selling or distributing a CD-ROM of examples from O’Reilly books does
require permission. Answering a question by citing this book and quoting example
code does not require permission. Incorporating a significant amount of example
code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the
title, author, publisher, and ISBN. For example: “sendmail, by Bryan Costales et al.
Copyright 2008 Bryan Costales et al., 978-0-596-51029-9.”
Additional Sources of Information
The source for the sendmail program comes with a document written by the send-
mail program’s authors that is required reading. Sendmail Installation and Opera-
tions Guide (located in doc/op in the source distribution) provides installation
instructions and a succinct description of the configuration file. Many vendors also
provide online manuals which might reveal vendor-specific customizations not docu-
mented in this book. Also, if you have the source, see the RELEASE_NOTES file and
all the */README files.
This is the Title of the Book, eMatter Edition

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
xxii
|
Preface
Other Books, Other Problems
Two topics that are only touched upon in this book are the Domain Name System
(DNS) and TCP/IP network communications. At a typical site, a significant number
of mail-related problems turn out to be problems with one of these other areas rather
than with sendmail.
The DNS is well documented in the book DNS and BIND, Fifth Edition by Paul
Albitz and Cricket Liu (O’Reilly).
The protocols used to communicate over the Internet are well documented in the
book TCP/IP Network Administration, Third Edition by Craig Hunt (O’Reilly).
Finally, many mail problems can be solved only by the system administrator. The
sendmail program runs as root and can be installed and managed only by root.The
art of functioning effectively as root is superbly covered in the UNIX System Adminis-
tration Handbook, Third Edition by Evi Nemeth, Garth Snyder, Scott Seebass, and
Trent R. Hein (Prentice Hall).
How to Contact Us
We have tested and verified the information in this book to the best of our ability,
but you might find that features have changed (or even that we have made mis-
takes!). 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 on or ask technical questions about this book, send email to:

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

This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Preface
|
xxiii
Safari® Books Online
When you see a Safari® Books Online icon on the cover of your
favorite technology book, that means the book is available online
through the O’Reilly Network Safari Bookshelf.
Safari offers a solution that’s better than e-books. It’s a virtual library that lets you
easily search thousands of top tech books, cut and paste code samples, download
chapters, and find quick answers when you need the most accurate, current informa-
tion. Try it for free at .
Acknowledgments
First and foremost, I must thank Greg Shapiro for his careful review of the new chap-
ter about Milters.
Bruce Mah and Sean Brennan were guinea pigs for the first and second editions,
respectively. Chris Fedde was guinea pig for the third edition. Scott Palmer bravely
functioned as guinea pig for the fourth edition. They set up and ran sendmail based
on early drafts and thereby uncovered omissions and mistakes that required correc-
tion. Gavin Cameron bravely applied the checkcompat() examples to real-world situ-
ations, thereby helping to debug that code for me. Mark D. Roth kindly reviewed the
ph database type and provided valuable clarification.
Needless to say, this book would not have been possible if Eric Allman had not writ-

ten sendmail in the first place.
For the second and fourth editions, Cricket Liu kindly reviewed the DNS chapter
and found several errors that slipped by everyone else.
George Jansen,
*
editor extraordinaire, has turned all my early drafts of new text into
a form suitable for publication. He has stuck with me through all editions and has
never tired.
Thanks and praise must go to Tim O’Reilly for agreeing to do this book in the first
place. His experience has shaped this book into its current form. He was aware of the
“big picture” throughout and kept his fingers on the pulse of the reader. Without his
advice, a book this complex and massive would have been impossible.
Additional thanks must go to Edie Freedman for gracefully accepting my unhappi-
ness with so many cover designs except the current one, which I consider perfect.
The production folks at O’Reilly did a yeoman’s job of achieving an outstanding fin-
ished book. For the previous editions a special thank you to Barbara Willette for
copyediting, Nancy Kotary for help with final production, Kismet McDonough-Chan
* Author of The Jesse James Scrapbook and The Fade-away ().
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
xxiv
|
Preface
for her help in each phase of the production, Chris Reilley for the figures, Mary Anne
Weeks Mayo for helping with quality control, Curt Degenhart, Madeleine Newell,
and Ellie Fountain Maden for making the edits, Seth Maislin for doing the index, and
Danny Marcus for proofreading.
For the third edition, a special thank you to Robert J. Denn for managing the project,
Darren Kelly for help with final production, Rob Romano and Jessamyn Read for the
figures, Mary Brady, Linley Dolby, Matt Hutchinson, and Claire Cloutier for helping

with quality control, Reg Aubry, Julie Hawks, Genevieve d’Entremont, and Judy
Hoer for providing production support, Brenda Miller for updating the index from
the second edition, and Audrey Doyle for proofreading.
For the fourth edition, thanks to Tatiana Apandi, Audrey Doyle, Colleen Gorman,
Mary Brady, John Bickelhaupt, and Marlowe Shaeffer for their work in editorial and
production.
Finally, thanks to a list of folks, each of whom helped in small but notable ways:
Paul Vixie; Neil Rickert; Keith Johnson; Paul Pomes; Frederick Avolio; John Hal-
leck; John Beck; Brad Knowles; Andrew Chang; Shau-Ping Lo; and the many who
sent interesting questions to the sendmail questions mailing list, and all the postings
to the comp.mail.sendmail news group.
—Bryan Costales

×