0109-0112.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 652 行
HTML
652 行
<HTML>
<HEAD>
<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:SMTP and POP</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311739 //-->
<!-- TITLE=RED HAT LINUX 2ND EDITION //-->
<!-- AUTHOR=DAVID PITTS ET AL //-->
<!-- PUBLISHER=MACMILLAN //-->
<!-- IMPRINT=SAMS PUBLISHING //-->
<!-- PUBLICATION DATE=1998 //-->
<!-- CHAPTER=07 //-->
<!-- PAGES=0097-0130 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0106-0108.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0113-0115.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-109"><P>Page 109</P></A>
<!-- CODE //-->
<PRE>
READ_ME conf.h mailq.1 queue.c stats.c
TRACEFLAGS convtime.c mailstats.h readcf.c sysexits.c
alias.c daemon.c main.c recipient.c sysexits.h
aliases deliver.c makesendmail safefile.c trace.c
aliases.0 domain.c map.c savemail.c udb.c
aliases.5 envelope.c mci.c sendmail.0 useful.h
arpadate.c err.c mime.c sendmail.8 usersmtp.c
cdefs.h headers.c newaliases.0 sendmail.h util.c
clock.c ldap_map.h newaliases.1 sendmail.hf version.c
</PRE>
<!-- END CODE //-->
<P>Thankfully, Eric Allman and the sendmail crew have done a fantastic job of making the
installation process very straightforward. To compile your new version of
sendmail, simply run
</P>
<!-- CODE SNIP //-->
<PRE>
[root@gonzo src]# makesendmail
</PRE>
<!-- END CODE SNIP //-->
<P>and watch it run. On the 2.0.30 kernel with Red Hat 4.2,
sendmail compiles without any warnings or errors.
</P>
<CENTER>
<TABLE BGCOLOR="#FFFF99">
<TR><TD><B>
WARNING
</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
Before installing the new sendmail configuration, be sure to make a backup of any files
that you are going to replace, especially the old
sendmail daemon you have. In the event the new
sendmail doesn't work for you, you will need to restore the old versions while
you troubleshoot the new version.
</BLOCKQUOTE></TD></TR>
</TABLE></CENTER>
</P>
<P>To install the new version of sendmail, first stop the currently running daemon with the
following command:
</P>
<!-- CODE SNIP //-->
<PRE>
[root@gonzo src]# /etc/rc.d/init.d/sendmail.init stop
</PRE>
<!-- END CODE SNIP //-->
<P>Then simply copy the new binary to its proper place:
</P>
<!-- CODE SNIP //-->
<PRE>
[root@gonzo src]# cp obj.Linux*/sendmail /usr/sbin/sendmail
</PRE>
<!-- END CODE SNIP //-->
<P>It is also a good idea to copy the new man pages over too:
</P>
<!-- CODE //-->
<PRE>
[root@gonzo src]# cp aliases.0 /usr/man/man5/aliases.5
[root@gonzo src]# cp mailq.0 /usr/man/man1/mailq.1
[root@gonzo src]# cp newaliases.0 /usr/man/man1/newaliases.1
[root@gonzo src]# cp sendmail.0 /usr/man/man8/sendmail.8
</PRE>
<!-- END CODE //-->
<P>With everything in place, you can restart the new daemon with the following:
</P>
<!-- CODE SNIP //-->
<PRE>
[root@gonzo src]# /etc/rc.d/init.d/sendmail.init start
</PRE>
<!-- END CODE SNIP //-->
<H4><A NAME="ch07_ 18">
sendmail.cf—The Configuration File
</A></H4>
<P>Now you've got a working sendmail, but like the Wizard of Oz's Scarecrow, it's brainless.
The sendmail.cf file provides sendmail with its brains, and because it's so important, this
section covers it in fairly excruciating detail. Don't worry if you don't understand everything in
this
</P>
<A NAME="PAGENUM-110"><P>Page 110</P></A>
<P>section the first time through. It will make more sense upon rereading, and after you've had
a chance to play with some configuration files of your own.
</P>
<P>sendmail's power lies in its flexibility, which comes from its configuration file,
sendmail.cf. sendmail.cf statements comprise a cryptic programming language that at first glance
doesn't inspire much confidence (but C language code probably didn't either the first time you saw
it). However, learning the sendmail.cf language isn't very hard, and you won't have to learn
the nitty-gritty details unless you plan to write a
sendmail.cf from scratch—a bad idea at best. You do need to learn enough to understand and adapt the V8
sendmail configuration file templates to your site's needs.
</P>
<H4><A NAME="ch07_ 19">
General Form of the Configuration File
</A></H4>
<P>Each line of the configuration file begins with a single command character that tells the
function and syntax of that line. Lines beginning with a
# are comments, and blank lines are ignored. Lines beginning with a space or tab are continuations of the preceding line,
although you should usually avoid continuations.
</P>
<P>Table 7.1 shows the command characters and their functions. This table is split into three
parts corresponding to the three main functions of a configuration file, which are covered later
in the chapter in the section "A Functional Description of the Configuration File."
</P>
<P>Table 7.1. sendmail.cf command characters.
</P>
<HR>
<TABLE WIDTH="360">
<TR><TD>
Command Character
</TD><TD>
Command Syntax and Example
</TD><TD>
Function
</TD></TR>
<TR><TD>
#
</TD><TD>
# comments are ignored.
</TD><TD>
A comment line.
</TD></TR>
<TR><TD>
</TD><TD>
Always use lots of comments.
</TD><TD>
</TD></TR>
<TR><TD>
</TD><TD>
# Standard RFC822 parsing
</TD><TD>
</TD></TR>
<TR><TD>
D
</TD><TD>
DX string
</TD><TD>
Defines a macro X to have
the string value string.
</TD></TR>
</TD><TD>
</TD><TD>
DMmailhub.gonzo.gov
</TD><TD>
</TD></TR>
<TR><TD>
C
</TD><TD>
CX word1, word2, and so on.
</TD><TD>
Defines a class X as word1,
word2, and so on.
</TD></TR>
<TR><TD>
</TD><TD>
Cwlocalhost myuucpname
</TD><TD>
</TD></TR>
<TR><TD>
F
</TD><TD>
FX/path/to/a/file
</TD><TD>
Defines a class X by reading
it from a file.
</TD></TR>
<TR><TD>
</TD><TD>
Fw/etc/mail/host_aliases
</TD><TD>
</TD></TR>
<TR><TD>
H
</TD><TD>
H?mailerflag?name:template
</TD><TD>
Defines a mail header.
</TD></TR>
</TD><TD>
</TD><TD>
H?F?From: $q
</TD><TD>
</TD></TR>
</TABLE>
<A NAME="PAGENUM-111"><P>Page 111</P></A>
<HR>
<TABLE WIDTH="360">
<TR><TD>
Command Character
</TD><TD>
Command Syntax and Example
Function
</TD></TR>
<TR><TD>
O
</TD><TD>
OX option arguments
</TD><TD>
Sets option X.
</TD></TR>
<TR><TD>
</TD><TD>
</TD><TD>
Most command-line options can be set in
sendmail.cf.
</TD></TR>
<TR><TD>
</TD><TD>
OL9 # sets the log level to 9.
</TD><TD>
</TD></TR>
<TR><TD>
P
</TD><TD>
Pclass=nn
</TD><TD>
Sets mail delivery prece-
dence based on the class of
the mail.
</TD></TR>
<TR><TD>
</TD><TD>
Pjunk=-100
</TD><TD>
</TD></TR>
<TR><TD>
V
</TD><TD>
Vn
</TD><TD>
Tells V8 sendmail the version level of the
configuration file.
</TD></TR>
<TR><TD>
</TD><TD>
V3
</TD><TD>
</TD></TR>
<TR><TD>
K
</TD><TD>
Kname class arguments.
</TD><TD>
Defines a key file (database
map).
</TD></TR>
<TR><TD>
</TD><TD>
Kuucphosts dbm /etc/mail/uucphsts
</TD><TD>
</TD></TR>
<TR><TD>
M
</TD><TD>
Mname,field_1=value_1,…
</TD><TD>
Defines a mailer.
</TD></TR>
<TR><TD>
</TD><TD>
Mprog,P=/bin/sh,F=lsD,A=sh -c $u
</TD><TD>
</TD></TR>
<TR><TD>
S
</TD><TD>
Snn
</TD><TD>
Begins a new rule set.
</TD><TD>
<TR><TD>
</TD><TD>
S22
</TD><TD>
</TD></TR>
<TR><TD>
R
</TD><TD>
Rlhs rhs comment
</TD><TD>
Defines a matching
/ rewriting rule.
</TD></TR>
<TR><TD>
</TD><TD>
R$+ $:$>22 call ruleset 22
</TD><TD>
</TD></TR>
</TABLE>
<H4><A NAME="ch07_ 20">
A Functional Description of the Configuration File
</A></H4>
<P>A configuration file does three things. First, it sets the environment for
sendmail by telling it what options you want set and the locations of the files and databases it uses.
</P>
<P>Second, a configuration file defines the characteristics of the mailers (delivery agents or
MTAs) that sendmail uses after it decides where to route a letter. All configuration files must
define local and program mailers to handle delivery to users on the local host; most also define one
or more SMTP mailers; and sites that must handle UUCP mail define UUCP mailers.
</P>
<P>Third, a configuration file specifies rulesets that rewrite sender and recipient addresses and
select mailers. All rulesets are user-defined, but some have special meaning to
sendmail. Ruleset 0, for example, is used to select a mailer. Rulesets 0, 1, 2, 3, and 4 all have special meaning
to
</P>
<A NAME="PAGENUM-112"><P>Page 112</P></A>
<P>sendmail and are processed in a particular order. (See the section "The
S and R Operators—Rulesets and Rewriting Rules" later in this chapter.)
</P>
<P>The following sections cover the operators in more detail, in the order in which they appear
in Table 7.1.
</P>
<H4><A NAME="ch07_ 21">
The D Operator—Macros
</A></H4>
<P>Macros are like shell variables. After you define a macro's value, you can refer to it later in
the configuration file, and its value will be substituted for the macro. For example, a
configuration file might have many lines that mention the hypothetical mail hub,
mailer.gonzo.gov. Rather than type that name over and over, you can define a macro
R (for relay mailer) as follows:
</P>
<!-- CODE SNIP //-->
<PRE>
DRmailer.gonzo.gov
</PRE>
<!-- END CODE SNIP //-->
<P>When sendmail encounters a $R in sendmail.cf, it substitutes the string
mailer.gonzo.gov.
</P>
<P>Macro names are always single characters. Quite a few macros are defined by
sendmail and shouldn't be redefined except to work around broken software.
sendmail uses lowercase letters for its predefined macros. Uppercase letters can be used freely. V8
sendmail's predefined macros are fully documented in section 5.1.2 of the SIOG.
</P>
<H4><A NAME="ch07_ 22">
The C and F Operators—Classes
</A></H4>
<P>Classes are similar to macros but are used for different purposes in rewriting
rules. (See "The S and R Operators—Rulesets and Rewriting Rules" later in this chapter.) As with
macros, classes are named by single characters. Lowercase letters are reserved to
sendmail and uppercase letters for user-defined classes. A class contains one or more words. For example, you could define
a class H containing all the hosts in the local domain as follows:
</P>
<!-- CODE SNIP //-->
<PRE>
CH larry moe curly
</PRE>
<!-- END CODE SNIP //-->
<P>For convenience, large classes can be continued on subsequent lines. The following
definition of the class H is the same as the preceding one:
</P>
<!-- CODE SNIP //-->
<PRE>
CH larry
CH moe
CH curly
</PRE>
<!-- END CODE SNIP //-->
<P>You can also define a class by reading its words from a file:
</P>
<!-- CODE SNIP //-->
<PRE>
CF/usr/local/lib/localhosts
</PRE>
<!-- END CODE SNIP //-->
<P>If the file /usr/local/lib/localhosts contains the words
larry, moe, and curly, one per line, this definition is equivalent to the preceding two.
</P>
<P>Why use macros and classes? The best reason is that they centralize information in the
configuration file. In the preceding example, if you decide to change the name of the mail
hub from mailer.gonzo.gov to mailhub.gonzo.gov, you have to change only the definition of
the $R macro remedy, and the configuration file will work as before. If the name
mailer.gonzo.gov
</P>
<P><CENTER>
<a href="0106-0108.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0113-0115.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?