⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unx41.htm

📁 Linux Unix揭密.高质量电子书籍.对学习Linux有大帮助,欢迎下载学习.
💻 HTM
📖 第 1 页 / 共 5 页
字号:

<P><BR></P>

<TR>

<TD>

<P>K</P>

<TD>

<P>Kname class arguments</P>

<TD>

<P>Define a key file (database map).</P>

<TR>

<TD>

<P><BR></P>

<TD>

<P><B>Kuucphosts dbm </B><B>/etc/mail/uucphsts</B></P>

<TD>

<P><BR></P>

<TR>

<TD>

<P>M</P>

<TD>

<P>Mname,field_1=value_1,...</P>

<TD>

<P>Define a<B> </B>mailer.</P>

<TR>

<TD>

<P><BR></P>

<TD>

<P><B>Mprog,P=/bin/sh,F=lsD,A=sh </B><B>-c $u</B></P>

<TD>

<P><BR></P>

<TR>

<TD>

<P>S</P>

<TD>

<P>Snn</P>

<TD>

<P>Begin a new rule-set.</P>

<TR>

<TD>

<P><BR></P>

<TD>

<P><B>S22</B></P>

<TD>

<P><BR></P>

<TR>

<TD>

<P>R</P>

<TD>

<P>Rlhs rhs comment</P>

<TD>

<P>Define a matching/rewriting rule.</P>

<TR>

<TD>

<P><BR></P>

<TD>

<P><B>R$+ $:$&gt;22  call ruleset 22</B></P>

<TD>

<P><BR></P></TABLE>

<H4 ALIGN="CENTER">

<CENTER><A ID="I29" NAME="I29">

<FONT SIZE=3><B>A Functional Description of the Configuration File</B>

<BR></FONT></A></CENTER></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.

<BR></P>

<P>Second, it 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.

<BR></P>

<P>Third, the 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 instance, is used to select a mailer. Rulesets 0, 
1, 2, 3, and 4 all have special meaning to sendmail and are processed in a particular order (see &quot;The S and R Operators&#151;Rulesets and Rewriting Rules&quot;) later in this chapter.

<BR></P>

<P>In the following sections we'll cover the operators in more detail, in the order in which they appear in Table 41.1.

<BR></P>

<H4 ALIGN="CENTER">

<CENTER><A ID="I30" NAME="I30">

<FONT SIZE=3><B>The </B><B><I>D</I></B><B> Operator&#151;Macros</B>

<BR></FONT></A></CENTER></H4>

<P>Macros are like shell variables. Once 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 instance, a configuration file might have many lines that mention our hypothetical 

mail hub, mailer.gonzo.gov. Rather than typing that name over and over, you can define a macro R (for relay mailer):

<BR></P>

<PRE>DRmailer.gonzo.gov</PRE>

<P>When sendmail encounters a $R in sendmail.cf, it substitutes the string mailer.gonzo.gov.

<BR></P>

<P>Macro names are always a single character. Quite a few macros are defined by sendmail and shouldn't be redefined except to work around broken software1. sendmail uses lower-case letters for its predefined macros. Uppercase letters may be used freely. V8 

sendmail's predefined macros are fully documented in section 5.1.2 of the SIOG.

<BR></P>

<H4 ALIGN="CENTER">

<CENTER><A ID="I31" NAME="I31">

<FONT SIZE=3><B>The </B><B><I>C</I></B><B> and </B><B><I>F</I></B><B> Operators&#151;Classes</B>

<BR></FONT></A></CENTER></H4>

<P>Classes are similar to macros but are used for different purposes in rewriting rules (see below, &quot;The S and R operators&#151;rulesets and rewriting rules&quot;). As with macros, classes are named by a single character. Lowercase letters are 
reserved to sendmail, and uppercase letters for user-defined classes. A class contains one or more words. For instance, you could define a class H containing all the hosts in the local domain:

<BR></P>

<PRE>CH larry moe curly</PRE>

<P>For convenience, large classes may be continued on subsequent lines. The following definition of the class H is exactly the same as the previous one:

<BR></P>

<PRE>CH larry

CH moe

CH curly</PRE>

<P>You can also define a class by reading its words from a file:

<BR></P>

<PRE>CF/usr/local/lib/localhosts</PRE>

<P>If the file /usr/local/lib/localhosts contains the words larry, moe, and curly, one per line, this definition is equivalent to the previous two.

<BR></P>

<P>Why use macros and classes? The best reason is that they centralize information in the configuration file. In the example above, if you decide to change the name of the mail hub from mailer.gonzo.gov to mailhub.gonzo.gov, you only have to change the 
definition of the $R macro remedyand the configuration file will work as before. If the name mailer.gonzo.gov is scattered throughout the file, you might forget to change it in some places. Also, if important information is centralized, you can comment it 

extensively in a single place. Because configuration files tend to be obscure at best, a liberal dose of comments is a good antidote to that sinking feeling you get when, six months later, you wonder why you made a change.

<BR></P>

<H5 ALIGN="CENTER">

<CENTER><A ID="I32" NAME="I32">

<FONT SIZE=3><B>The </B><B><I>H</I></B><B> Operator&#151;Header Definitions</B>

<BR></FONT></A></CENTER></H5>

<P>You probably won't want to change the header definitions given in the V8 sendmail configuration files because they already follow accepted standards. Here are some sample headers:

<BR></P>

<PRE>H?D?Date: $a

H?F?Resent-From: $q

H?F?From: $q

H?x?Full-Name: $x</PRE>

<P>Note that header definitions can use macros, which are expanded, when inserted into a letter. For instance, the $x macro used in the Full-Name: header definition above expands to the full name of the sender.

<BR></P>

<P>The optional ?<I>mailerflag</I>? construct tells sendmail to insert a header only if the chosen mailer has that mailer flag set. (See &quot;The M Operator&#151;Mailer Definitions&quot; later in this chapter.)

<BR></P>

<P>Suppose that the definition of your local mailer has a flag Q, and sendmail selects that mailer to deliver a letter. If your configuration file contains a header definition like the following one, sendmail will insert that header into letters delivered 

through the local mailer, substituting the value of the macro $F:

<BR></P>

<PRE>H?Q?X-Fruit-of-the-day: $F</PRE>

<P>Why would you use the ?mailerflag? feature? Different protocols may require different mail headers. Since they also need different mailers, you can define appropriate mailer flags for each in the mailer definition, and use the ?<I>mailerflag</I>? 
construct in the header definition to tell sendmail whether to insert the header.

<BR></P>

<H5 ALIGN="CENTER">

<CENTER><A ID="I33" NAME="I33">

<FONT SIZE=3><B>The </B><B><I>O</I></B><B> Operator&#151;Setting Options</B>

<BR></FONT></A></CENTER></H5>

<P>sendmail has many options that change its operation or tell it the location of files it uses. Most of them may be given either on the command line or in the configuration file. For instance, the location of the aliases file may be specified in either 
place. To specify the aliases file on the command line, you use the -o option:

<BR></P>

<PRE>$ sendmail -oA/etc/mail/aliases [other arguments...]</PRE>

<P>To do the same thing in the configuration file, you include a line like this:

<BR></P>

<PRE>OA/etc/mail/aliases</PRE>

<P>Either use is equivalent, but options such as the location of the aliases file rarely change and most people set them in sendmail.cf. The V8 sendmail options are fully described in section 5.1.6 of the SIOG.

<BR></P>

<H5 ALIGN="CENTER">

<CENTER><A ID="I34" NAME="I34">

<FONT SIZE=3><B>The </B><B><I>P</I></B><B> Operator&#151;Mail Precedence</B>

<BR></FONT></A></CENTER></H5>

<P>Users can include mail headers indicating the relative importance of their mail, and sendmail can use those headers to decide the priority of competing letters. Precedences for V8 sendmail are given as:

<BR></P>

<PRE>Pspecial-delivery=100

Pfirst-class=0

Plist=-30

Pbulk=-60

Pjunk=-100</PRE>

<P>If a user who runs a large mailing list includes the header Precedence: bulk in his letters, sendmail gives it a lower priority than a letter with the header Precedence: first-class.

<BR></P>

<H5 ALIGN="CENTER">

<CENTER><A ID="I35" NAME="I35">

<FONT SIZE=3><B>The </B><B><I>V</I></B><B> Operator&#151;</B><B><I>sendmail.cf</I></B><B> Version Levels</B>

<BR></FONT></A></CENTER></H5>

<P>As V8 sendmail evolves its author adds new features. The V operator lets V8 sendmail know what features it should expect to find in your configuration file. Older versions of sendmail don't understand this command. Section 5.1.8 of the SIOG explains the 

different configuration file version levels in detail.

<BR></P>

<HR ALIGN=CENTER>

<NOTE>

<IMG SRC="note.gif" WIDTH = 35 HEIGHT = 35><B>NOTE:</B> The configuration file version level does not correspond to the sendmail version level. V8 sendmail understands versions 1 through 5 of configuration files, and there is no such thing as a version 8 
configuration file.

<BR></NOTE>

<HR ALIGN=CENTER>

<H5 ALIGN="CENTER">

<CENTER><A ID="I36" NAME="I36">

<FONT SIZE=3><B>The </B><B><I>K</I></B><B> Operator&#151;Key Files</B>

<BR></FONT></A></CENTER></H5>

<P>sendmail has always used keyed databases, for instance, the aliases databases. Given the key postmaster, sendmail looks up the data associated with that key and returns the names of the accounts to which the postmaster's mail should be delivered. V8 
sendmail extends this concept to arbitrary databases, including NIS maps (Sun's Network Information Service, formerly known as Yellow Pages or YP). The K operator tells sendmail the location of the database, its class, and how to access it. V8 sendmail 
supports the following classes of user-defined databases: dbm, btree, hash, and NIS. Depending on which of these databases you use, you must compile sendmail with different options. See section 5.1.9 of the SIOG for the lowdown on key files.

<BR></P>

<H5 ALIGN="CENTER">

<CENTER><A ID="I37" NAME="I37">

<FONT SIZE=3><B>The </B><B><I>M</I></B><B> Operator&#151;Mailer Definitions</B>

<BR></FONT></A></CENTER></H5>

<P>Mailers are either MTAs or final delivery agents. Recall that the aliases file allows you to send mail to a login name (which might be aliased to a remote user), a program, or a file. A special mailer may be defined for each purpose. And even though the 

SMTP MTA is built-in, it must have a mailer definition to tailor sendmail's SMTP operations.

<BR></P>

<P>Mailer definitions are important because all recipient addresses must resolve to a mailer in ruleset 0. Resolving to a mailer is just another name for sendmail's main function, mail routing. For instance, resolving to the local mailer routes the letter 

to a local user via the final delivery agent defined in that mailer (usually /bin/mail), and resolving to the SMTP mailer routes the letter to another host via sendmail's built-in SMTP transport, as defined in the SMTP mailer. A concrete example of a 
mailer definition will make this clearer. Since sendmail requires a local mailer definition, let's look at that:

<BR></P>

<PRE>Mlocal, P=/bin/mail, F=lsDFMfSn, S=10, R=20, A=mail -d $u</PRE>

<P>All mailer definitions begin with the M operator and the name of the mailer, in this case local. Other fields follow, separated by commas. Each field consists of a field name and its value, separated by an equals sign (=). The allowable fields are 
explained in section 5.1.4 of the SIOG.

<BR></P>

<P>In the local mailer definition above, the P= equivalence gives the pathname of the program to run to deliver the mail, /bin/mail. The F= field gives the sendmail flags for the local mailer. (See also &quot;The H Operator&#151;Defining Headers&quot; 
earlier in the chapter.) These flags are not passed to the command mentioned in the P= field but are used by sendmail to modify its operation depending on the mailer it chooses. For instance, sendmail usually drops its super-user status before invoking 
mailers, but you can use the S mailer flag to tell sendmail to retain it for certain mailers.

<BR></P>

<P>The S= and R= fields specify rulesets for sendmail to use in rewriting sender and recipient ad

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -