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

📄 unx41.htm

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

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

<FONT SIZE=3><B><I>sendmail</I></B><B> as Mail Router</B>

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

<P>sendmail is primarily a mail router, meaning it takes a letter, inspects the recipient addresses, and decides the best way to send it. How does sendmail do this?

<BR></P>

<P>sendmail determines some of the information it needs on its own, like the current time and the name of the host on which it's running, but most of its brains are supplied by you, the postmaster, in the form of a configuration file, sendmail.cf. This 
somewhat cryptic file tells sendmail exactly how you want various kinds of mail handled. It is extremely flexible and powerful, and at first glance seemingly inscrutable. However, one of the strengths of V8 sendmail is its set of modular configuration file 

building blocks. Most sites can easily construct their configuration files from these modules, and many examples are included. Writing a configuration file from scratch is a daunting task and you should avoid it if you can.

<BR></P>

<H5 ALIGN="CENTER">

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

<FONT SIZE=3><B><I>sendmail</I></B><B> as MTA&#151;Client (Sender) and Server (Receiver) SMTP</B>

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

<P>As mentioned before, sendmail can function as an MTA since it understands the SMTP protocol (V8 sendmail also understands ESMTP). Because SMTP is a connection-oriented protocol, there is always a client and a server (also known as a sender and a 
receiver). The SMTP client delivers a letter to an SMTP server, which listens continuously on its com-puter's SMTP port. sendmail can be an SMTP client or an SMTP server. When run by an MUA, it becomes an SMTP client and speaks client-side SMTP to an SMTP 

server (not necessarily another sendmail program). When your system boots and it starts in daemon mode, it runs continuously, listening on the SMTP port for incoming mail.

<BR></P>

<H5 ALIGN="CENTER">

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

<FONT SIZE=3><B><I>sendmail</I></B><B> as a Final Delivery Agent (NOT!)</B>

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

<P>One thing sendmail doesn't do is final delivery. sendmail's author wisely chose to leave this task to other programs. sendmail is a big, complicated program that runs with super-user privileges, an almost guaranteed recipe for security problems, and 
there have been quite a few in sendmail's past. The additional complexity of final mail delivery is the last thing sendmail needs.

<BR></P>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B><I>sendmail</I></B><B>'s Auxiliary Files</B>

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

<P>sendmail depends on a number of auxiliary files to do its job. The most important are the aliases file and the configuration file, sendmail.cf. The statistics file, sendmail.st, can be created or not depending on whether you want the statistics. 
sendmail.hf is the SMTP help file, and should be installed if you intend to run sendmail as an SMTP server (most sites do). That's all that needs to be said about sendmail.st and sendmail.hf (there are other auxilary files that are covered in the SIOG), 
but the aliases and sendmail.cf files are important enough to be covered in their own sections.

<BR></P>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B>The Aliases File</B>

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

<P>sendmail always checks recipient addresses for aliases, which are alternate names for a recipient. For instance, each Internet site is required to have a valid address postmaster to which mail problems may be reported. Most sites don't have an actual 
account of that name but divert the postmaster's mail to the person or persons responsible for e-mail administration. For instance, at the mythical site gonzo.gov, the users joe and betty are jointly responsible for e-mail administration, and the aliases 
file has the following entry:

<BR></P>

<PRE>postmaster: joe, betty</PRE>

<P>This line tells sendmail that mail to postmaster should instead be delivered to the login names joe and betty. In fact, those names could also be aliases:

<BR></P>

<PRE>postmaster: firstshiftops, secondshiftops, thirdshiftops

firstshiftops: joe, betty

secondshiftops: lou, emma

thirdshiftops: ben, mark, clara</PRE>

<P>In all of these examples, the alias name is the part on the left side of the colon, and the aliases for those names are on the right side. sendmail repeatedly evaluates aliases until they resolve to a real user or a remote address. In the previous 
example, to resolve the alias postmaster, sendmail first expands it into the list of recipients firstshiftops, secondshiftops, and thirdshiftops and then expands each of these into the final list, joe, betty, lou, emma, ben, mark, and clara.

<BR></P>

<P>Although the right side of an alias may refer to a remote host, the left side may not. The alias joe: joe@whizzer.com is legal, but joe@gonzo.gov: joe@whizzer.com is not.

<BR></P>

<H5 ALIGN="CENTER">

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

<FONT SIZE=3><B>Reading Aliases from a File&#151;the </B><B><I>:include:</I></B><B> Directive</B>

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

<P>Aliases may be used to create mailing lists (in the example above, the alias postmaster is in effect a mailing list for the local postmasters). For big or frequently changing lists, you can use the :include: alias form to direct sendmail to read the 
list members from a file. If the aliases file contains the line:

<BR></P>

<PRE>homeboys: :include:/home/alphonse/homeboys.aliases</PRE>

<P>and the file /home/alphonse/homeboys.aliases contains:

<BR></P>

<PRE>alphonse

joe

betty

george</PRE>

<P>The effect is the same as the alias:

<BR></P>

<PRE>homeboys: alphonse, joe, betty, george</PRE>

<P>This is handy for mailing lists that change frequently, or those managed by users other than the postmaster. If you find a user is asking for frequent changes to a mail alias, you may want to put it under her control.

<BR></P>

<H5 ALIGN="CENTER">

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

<FONT SIZE=3><B>Mail to Programs</B>

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

<P>The aliases file also may be used to send the contents of e-mail to a program. For instance, many mailing lists are set up so that you can get information about the list or subscribe to it by sending a letter to a special address, <I>list</I>-request. 
The letter usually contains a single word in its body, such as help or subscribe, which causes a program to mail an information file to the sender. Suppose that the gonzo mailing list has such an address called gonzo-request:

<BR></P>

<PRE>gonzo-request: |/usr/local/lib/auto-gonzo-reply</PRE>

<P>In this form of alias, the pipe sign (|) tells sendmail to use the program mailer, which is usually defined as /bin/sh (see &quot;The M command&#151;defining mailers&quot; below). sendmail feeds the message to the standard input of 
/usr/local/lib/auto-gonzo-reply, and if it exits normally, sendmail considers the letter to be delivered.

<BR></P>

<H5 ALIGN="CENTER">

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

<FONT SIZE=3><B>Mail to Files</B>

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

<P>You can also create an alias that causes sendmail to send mail to files. An example of this is the alias nobody, which is common on systems running the Network File System (NFS):

<BR></P>

<PRE>nobody: /dev/null</PRE>

<P>Aliases that specify files cause sendmail to append its message to the named file. Because the special file /dev/null is the UNIX bit-bucket, this alias simply throws mail away.

<BR></P>

<H3 ALIGN="CENTER">

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

<FONT SIZE=4><B>Setting up </B><B><I>sendmail</I></B>

<BR></FONT></A></CENTER></H3>

<P>The easiest way to show you how to set up sendmail is to use a concrete example. However, because sendmail runs under many different versions of UNIX, your system may vary from the examples shown below. For the sake of concreteness, these examples 
assume that you're setting up sendmail on a Solaris 2.3 system, Sun Microsystem's version of SVR4 UNIX.

<BR></P>

<P>First you must obtain the source and compile sendmail. Next you must choose a sendmail.cf file that closely models your site's requirements and tinker with it as necessary. Then you must test sendmail and its configuration file. Finally, you must 
install sendmail, sendmail.cf, and other auxiliary files.

<BR></P>

<P>Those are the basic steps, but depending on where you install sendmail, you may also have to modify a file in the directory /etc/init.d so that sendmail will be started correctly when the system boots. In addition, if your system doesn't already have 
one, you must create an aliases file, often named /usr/lib/aliases or /etc/mail/aliases (the location of the aliases file is given in sendmail.cf, so you can put it wherever you want). You may also have to make changes to your system's DNS database, but 
that won't be covered here.

<BR></P>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B>Obtaining the Source</B>

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

<P>sendmail version 8.6.9 is on the UNIX Unleashed CD. This is the most recent version available as this book goes to press, and it is the version documented in the O'Reilly book sendmail. However, if your site is on the Internet and you want to obtain the 

absolutely latest version, ftp to the host ftp.cs.berkeley.edu and look in the directory ~ftp/pub/ucb/sendmail. Use the following steps to download it:

<BR></P>

<PRE>$ ftp ftp.cs.berkeley.edu

Connected to ftp.cs.berkeley.edu.

220 kohler FTP server (Version wu-2.4(4) Fri May 6 16:09:33 PDT 1994) ready.

Name (ftp.cs.berkeley.edu:yourname): <B>anonymous</B>

331 Guest login ok, send your complete e-mail address as password.

Password: (Type your e-mail address)

230 Guest login ok, access restrictions apply.

ftp&gt; cd ucb/sendmail

250-This directory contains sendmail source distributions, currently for

250-Release 8. The latest version is in four files:

250-

250-   sendmail.${VER}.base.tar.Z &#151; the base system source &amp; documentation.

250-   sendmail.${VER}.cf.tar.Z &#151; configuration files.

250-   sendmail.${VER}.misc.tar.Z &#151; miscellaneous support programs.

250-   sendmail.${VER}.xdoc.tar.Z &#151; extended documentation, with postscript.

250-

250-The status of various ${VER}s is:

250-8.6.9  This is the version documented in the O'Reilly sendmail book.

250-       and which will be on the 4.4BSD-Lite tape. The files

250-       sendmail.8.6.[123456789].patch will upgrade an 8.6 source to

250-       this version (apply all of them).

250-8.6.8  The previous version. It fixes some significant security

250-       problems; you should be running at least this version.

250-

250 CWD command successful.

ftp&gt; binary

200 Type set to I.

ftp&gt; mget sendmail.8.6.9.base.tar.Z sendmail.8.6.9.cf.tar.Z

mget sendmail.8.6.9.base.tar.Z? <B>y</B>

200 PORT command successful.

150 Opening BINARY mode data connection for sendmail.8.6.9.base.tar.Z (500945 bytes).

226 Transfer complete.

local: sendmail.8.6.9.base.tar.Z remote: sendmail.8.6.9.base.tar.Z

500945 bytes received in 14 seconds (34 Kbytes/s)

mget sendmail.8.6.9.cf.tar.Z? <B>y</B>

200 PORT command successful.

150 Opening BINARY mode data connection for sendmail.8.6.9.cf.tar.Z (199863 bytes).

226 Transfer complete.

local: sendmail.8.6.9.cf.tar.Z remote: sendmail.8.6.9.cf.tar.Z

199863 bytes received in 3.3 seconds (59 Kbytes/s)

ftp&gt; <B>quit</B>

221 Goodbye.</PRE>

<P>Note that the exact name of the files to download differs depending on the current version of V8 sendmail, in this case version 8.6.9. Also, because the files are compressed, you must give ftp the binary command before transferring them. Note too that 
you should include your complete e-mail address as the password, for instance, mylogin@gonzo.gov. You may also wish to download the extended documentation and the support programs, which in this example would have been contained in the files 
sendmail.8.6.9.xdoc.tar.Z and sendmail.8.6.9.misc.tar.Z.

<BR></P>

<H4 ALIGN="CENTER">

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

<FONT SIZE=3><B>Unpacking the Source and Compiling </B><B><I>sendmail</I></B>

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

<P>Now that you've got the source, you need to unpack it. Because it's a compressed tar image, you must first decompress it and then extract the individual files from the tar archive. If you're using the version from the CD-ROM, these steps are not 
necessary.

<BR></P>

<PRE>$ mkdir /usr/src/local/sendmail

$ mv sendmail.8.6.9.* /usr/src/local/sendmail

$ cd /usr/src/local/sendmail

$ uncompress *Z

$ ls

sendmail.8.6.9.base.tar sendmail.8.6.9.cf.tar

$ tar xf sendmail.8.6.9.base.tar; tar xf sendmail.8.6.9.cf.tar

$ ls -CF

FAQ                    cf/                       sendmail.8.6.9.cf.tar

KNOWNBUGS              doc/                      src/

Makefile               mailstats/                test/

READ_ME                makemap/

RELEASE_NOTES          sendmail.8.6.9.base.tar

$ rm *tar</PRE>

<P>Now you're almost ready to compile sendmail, but first read the following files, which contain the latest news pertinent to the specific release of sendmail you've downloaded:

<BR></P>

<PRE>FAQ

RELEASE_NOTES

KNOWNBUGS

READ_ME</PRE>

<P>Now run cd and ls to see what files are in the source directory:

<BR></P>

<PRE>$ cd src

$ ls

Makefile               Makefile.SunOS.5.1     mailq.1

Makefile.386BSD        Makefile.SunOS.5.2     mailstats.h

Makefile.AIX           Makefile.SunOS.5.x     main.c

Makefile.AUX           Makefile.Titan         makesendmail

Makefile.BSD43         Makefile.ULTRIX        map.c

Makefile.BSDI          Makefile.UMAX          mci.c

Makefile.CLIX          Makefile.Utah          newaliases.1

⌨️ 快捷键说明

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