home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / share / doc / smm / 16.sendmail / intro.me next >
Encoding:
Text File  |  1991-04-17  |  38.3 KB  |  1,479 lines

  1. .\" Copyright (c) 1983 Eric P. Allman
  2. .\" Copyright (c) 1988 The Regents of the University of California.
  3. .\" All rights reserved.
  4. .\"
  5. .\" Redistribution and use in source and binary forms, with or without
  6. .\" modification, are permitted provided that the following conditions
  7. .\" are met:
  8. .\" 1. Redistributions of source code must retain the above copyright
  9. .\"    notice, this list of conditions and the following disclaimer.
  10. .\" 2. Redistributions in binary form must reproduce the above copyright
  11. .\"    notice, this list of conditions and the following disclaimer in the
  12. .\"    documentation and/or other materials provided with the distribution.
  13. .\" 3. All advertising materials mentioning features or use of this software
  14. .\"    must display the following acknowledgement:
  15. .\"    This product includes software developed by the University of
  16. .\"    California, Berkeley and its contributors.
  17. .\" 4. Neither the name of the University nor the names of its contributors
  18. .\"    may be used to endorse or promote products derived from this software
  19. .\"    without specific prior written permission.
  20. .\"
  21. .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22. .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25. .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27. .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28. .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30. .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31. .\" SUCH DAMAGE.
  32. .\"
  33. .\"    @(#)intro.me    6.5 (Berkeley) 4/17/91
  34. .\"
  35. .\"    pic -Pxx intro.me | ditroff -me -Pxx
  36. .eh 'SMM:16-%''SENDMAIL \*- An Internetwork Mail Router'
  37. .oh 'SENDMAIL \*- An Internetwork Mail Router''SMM:16-%'
  38. .nr si 3n
  39. .if n .ls 2
  40. .+c
  41. .(l C
  42. .sz 14
  43. SENDMAIL \*- An Internetwork Mail Router
  44. .sz
  45. .sp
  46. Eric Allman\(dg
  47. .sp 0.5
  48. .i
  49. University of California, Berkeley
  50. Mammoth Project
  51. .)l
  52. .sp
  53. .(l F
  54. .ce
  55. ABSTRACT
  56. .sp \n(psu
  57. Routing mail through a heterogenous internet presents many new
  58. problems.  Among the worst of these is that of address mapping.
  59. Historically, this has been handled on an
  60. .i "ad hoc"
  61. basis.  However,
  62. this approach has become unmanageable as internets grow.
  63. .sp \n(psu
  64. Sendmail acts a unified "post office" to which all mail can be
  65. submitted.  Address interpretation is controlled by a production
  66. system, which can parse both domain-based addressing and old-style
  67. .i "ad hoc"
  68. addresses.
  69. The production system is powerful
  70. enough to rewrite addresses in the message header to conform to the
  71. standards of a number of common target networks, including old
  72. (NCP/RFC733) Arpanet, new (TCP/RFC822) Arpanet, UUCP, and Phonenet.
  73. Sendmail also implements an SMTP server, message
  74. queueing, and aliasing.
  75. .)l
  76. .sp 2
  77. .(f
  78. \(dgA considerable part of this work
  79. was done while under the employ
  80. of the INGRES Project
  81. at the University of California at Berkeley
  82. and at Britton Lee.
  83. .)f
  84. .pp
  85. .i Sendmail
  86. implements a general internetwork mail routing facility,
  87. featuring aliasing and forwarding,
  88. automatic routing to network gateways,
  89. and flexible configuration.
  90. .pp
  91. In a simple network,
  92. each node has an address,
  93. and resources can be identified
  94. with a host-resource pair;
  95. in particular,
  96. the mail system can refer to users
  97. using a host-username pair.
  98. Host names and numbers have to be administered by a central authority,
  99. but usernames can be assigned locally to each host.
  100. .pp
  101. In an internet,
  102. multiple networks with different characterstics
  103. and managements
  104. must communicate.
  105. In particular,
  106. the syntax and semantics of resource identification change.
  107. Certain special cases can be handled trivially
  108. by
  109. .i "ad hoc"
  110. techniques,
  111. such as
  112. providing network names that appear local to hosts
  113. on other networks,
  114. as with the Ethernet at Xerox PARC.
  115. However,  the general case is extremely complex.
  116. For example,
  117. some networks require point-to-point routing,
  118. which simplifies the database update problem
  119. since only adjacent hosts must be entered
  120. into the system tables,
  121. while others use end-to-end addressing.
  122. Some networks use a left-associative syntax
  123. and others use a right-associative syntax,
  124. causing ambiguity in mixed addresses.
  125. .pp
  126. Internet standards seek to eliminate these problems.
  127. Initially, these proposed expanding the address pairs
  128. to address triples,
  129. consisting of
  130. {network, host, resource}
  131. triples.
  132. Network numbers must be universally agreed upon,
  133. and hosts can be assigned locally
  134. on each network.
  135. The user-level presentation was quickly expanded
  136. to address domains,
  137. comprised of a local resource identification
  138. and a hierarchical domain specification
  139. with a common static root.
  140. The domain technique
  141. separates the issue of physical versus logical addressing.
  142. For example,
  143. an address of the form
  144. .q "eric@a.cc.berkeley.arpa"
  145. describes only the logical
  146. organization of the address space.
  147. .pp
  148. .i Sendmail
  149. is intended to help bridge the gap
  150. between the totally
  151. .i "ad hoc"
  152. world
  153. of networks that know nothing of each other
  154. and the clean, tightly-coupled world
  155. of unique network numbers.
  156. It can accept old arbitrary address syntaxes,
  157. resolving ambiguities using heuristics
  158. specified by the system administrator,
  159. as well as domain-based addressing.
  160. It helps guide the conversion of message formats
  161. between disparate networks.
  162. In short,
  163. .i sendmail
  164. is designed to assist a graceful transition
  165. to consistent internetwork addressing schemes.
  166. .sp
  167. .pp
  168. Section 1 discusses the design goals for
  169. .i sendmail .
  170. Section 2 gives an overview of the basic functions of the system.
  171. In section 3,
  172. details of usage are discussed.
  173. Section 4 compares
  174. .i sendmail
  175. to other internet mail routers,
  176. and an evaluation of
  177. .i sendmail
  178. is given in section 5,
  179. including future plans.
  180. .sh 1 "DESIGN GOALS"
  181. .pp
  182. Design goals for
  183. .i sendmail
  184. include:
  185. .np
  186. Compatibility with the existing mail programs,
  187. including Bell version 6 mail,
  188. Bell version 7 mail
  189. [UNIX83],
  190. Berkeley
  191. .i Mail
  192. [Shoens79],
  193. BerkNet mail
  194. [Schmidt79],
  195. and hopefully UUCP mail
  196. [Nowitz78a, Nowitz78b].
  197. ARPANET mail
  198. [Crocker77a, Postel77]
  199. was also required.
  200. .np
  201. Reliability, in the sense of guaranteeing
  202. that every message is correctly delivered
  203. or at least brought to the attention of a human
  204. for correct disposal;
  205. no message should ever be completely lost.
  206. This goal was considered essential
  207. because of the emphasis on mail in our environment.
  208. It has turned out to be one of the hardest goals to satisfy,
  209. especially in the face of the many anomalous message formats
  210. produced by various ARPANET sites.
  211. For example,
  212. certain sites generate improperly formated addresses,
  213. occasionally
  214. causing error-message loops.
  215. Some hosts use blanks in names,
  216. causing problems with
  217. UNIX mail programs that assume that an address
  218. is one word.
  219. The semantics of some fields
  220. are interpreted slightly differently
  221. by different sites.
  222. In summary,
  223. the obscure features of the ARPANET mail protocol
  224. really
  225. .i are
  226. used and
  227. are difficult to support,
  228. but must be supported.
  229. .np
  230. Existing software to do actual delivery
  231. should be used whenever possible.
  232. This goal derives as much from political and practical considerations
  233. as technical.
  234. .np
  235. Easy expansion to
  236. fairly complex environments,
  237. including multiple
  238. connections to a single network type
  239. (such as with multiple UUCP or Ether nets
  240. [Metcalfe76]).
  241. This goal requires consideration of the contents of an address
  242. as well as its syntax
  243. in order to determine which gateway to use.
  244. For example,
  245. the ARPANET is bringing up the
  246. TCP protocol to replace the old NCP protocol.
  247. No host at Berkeley runs both TCP and NCP,
  248. so it is necessary to look at the ARPANET host name
  249. to determine whether to route mail to an NCP gateway
  250. or a TCP gateway.
  251. .np
  252. Configuration should not be compiled into the code.
  253. A single compiled program should be able to run as is at any site
  254. (barring such basic changes as the CPU type or the operating system).
  255. We have found this seemingly unimportant goal
  256. to be critical in real life.
  257. Besides the simple problems that occur when any program gets recompiled
  258. in a different environment,
  259. many sites like to
  260. .q fiddle
  261. with anything that they will be recompiling anyway.
  262. .np
  263. .i Sendmail
  264. must be able to let various groups maintain their own mailing lists,
  265. and let individuals specify their own forwarding,
  266. without modifying the system alias file.
  267. .np
  268. Each user should be able to specify which mailer to execute
  269. to process mail being delivered for him.
  270. This feature allows users who are using specialized mailers
  271. that use a different format to build their environment
  272. without changing the system,
  273. and facilitates specialized functions
  274. (such as returning an
  275. .q "I am on vacation"
  276. message).
  277. .np
  278. Network traffic should be minimized
  279. by batching addresses to a single host where possible,
  280. without assistance from the user.
  281. .pp
  282. These goals motivated the architecture illustrated in figure 1.
  283. .(z
  284. .hl
  285. .ie t \
  286. \{\
  287. .ie !"\*(.T"" \
  288. \{\
  289. .PS
  290. boxht = 0.5i
  291. boxwid = 1.0i
  292.  
  293.     down
  294. S:    [
  295.         right
  296.     S1:    box "sender1"
  297.         move
  298.         box "sender2"
  299.         move
  300.     S3:    box "sender3"
  301.     ]
  302.     arrow
  303. SM:    box "sendmail" wid 2i ht boxht
  304.     arrow
  305. M:    [
  306.         right
  307.     M1:    box "mailer1"
  308.         move
  309.         box "mailer2"
  310.         move
  311.     M3:    box "mailer3"
  312.     ]
  313.  
  314.     arrow from S.S1.s to 1/2 between SM.nw and SM.n
  315.     arrow from S.S3.s to 1/2 between SM.n and SM.ne
  316.  
  317.     arrow from 1/2 between SM.sw and SM.s to M.M1.n
  318.     arrow from 1/2 between SM.s and SM.se to M.M3.n
  319. .PE
  320. .\}
  321. .el \
  322. .    sp 18
  323. .\}
  324. .el \{\
  325. .(c
  326. +---------+   +---------+   +---------+
  327. | sender1 |   | sender2 |   | sender3 |
  328. +---------+   +---------+   +---------+
  329.      |         |             |
  330.      +----------+  +  +----------+
  331.         |  |  |
  332.         v  v  v
  333.             +-------------+
  334.             |   sendmail  |
  335.             +-------------+
  336.         |  |  |
  337.      +----------+  +  +----------+
  338.      |         |             |
  339.      v             v             v
  340. +---------+   +---------+   +---------+
  341. | mailer1 |   | mailer2 |   | mailer3 |
  342. +---------+   +---------+   +---------+
  343. .)c
  344. .\}
  345.  
  346. .ce
  347. Figure 1 \*- Sendmail System Structure.
  348. .hl
  349. .)z
  350. The user interacts with a mail generating and sending program.
  351. When the mail is created,
  352. the generator calls
  353. .i sendmail ,
  354. which routes the message to the correct mailer(s).
  355. Since some of the senders may be network servers
  356. and some of the mailers may be network clients,
  357. .i sendmail
  358. may be used as an internet mail gateway.
  359. .sh 1 "OVERVIEW"
  360. .sh 2 "System Organization"
  361. .pp
  362. .i Sendmail
  363. neither interfaces with the user
  364. nor does actual mail delivery.
  365. Rather,
  366. it collects a message
  367. generated by a user interface program (UIP)
  368. such as Berkeley
  369. .i Mail ,
  370. MS
  371. [Crocker77b],
  372. or MH
  373. [Borden79],
  374. edits the message as required by the destination network,
  375. and calls appropriate mailers
  376. to do mail delivery or queueing for network transmission\**.
  377. .(f
  378. \**except when mailing to a file,
  379. when
  380. .i sendmail
  381. does the delivery directly.
  382. .)f
  383. This discipline allows the insertion of new mailers
  384. at minimum cost.
  385. In this sense 
  386. .i sendmail
  387. resembles the Message Processing Module (MPM)
  388. of [Postel79b].
  389. .sh 2 "Interfaces to the Outside World"
  390. .pp
  391. There are three ways
  392. .i sendmail
  393. can communicate with the outside world,
  394. both in receiving and in sending mail.
  395. These are using the conventional UNIX
  396. argument vector/return status,
  397. speaking SMTP over a pair of UNIX pipes,
  398. and speaking SMTP over an interprocess(or) channel.
  399. .sh 3 "Argument vector/exit status"
  400. .pp
  401. This technique is the standard UNIX method
  402. for communicating with the process.
  403. A list of recipients is sent in the argument vector,
  404. and the message body is sent on the standard input.
  405. Anything that the mailer prints
  406. is simply collected and sent back to the sender
  407. if there were any problems.
  408. The exit status from the mailer is collected
  409. after the message is sent,
  410. and a diagnostic is printed if appropriate.
  411. .sh 3 "SMTP over pipes"
  412. .pp
  413. The SMTP protocol
  414. [Postel82]
  415. can be used to run an interactive lock-step interface
  416. with the mailer.
  417. A subprocess is still created,
  418. but no recipient addresses are passed to the mailer
  419. via the argument list.
  420. Instead, they are passed one at a time
  421. in commands sent to the processes standard input.
  422. Anything appearing on the standard output
  423. must be a reply code
  424. in a special format.
  425. .sh 3 "SMTP over an IPC connection"
  426. .pp
  427. This technique is similar to the previous technique,
  428. except that it uses a 4.2bsd IPC channel
  429. [UNIX83].
  430. This method is exceptionally flexible
  431. in that the mailer need not reside
  432. on the same machine.
  433. It is normally used to connect to a sendmail process
  434. on another machine.
  435. .sh 2 "Operational Description"
  436. .pp
  437. When a sender wants to send a message,
  438. it issues a request to
  439. .i sendmail
  440. using one of the three methods described above.
  441. .i Sendmail
  442. operates in two distinct phases.
  443. In the first phase,
  444. it collects and stores the message.
  445. In the second phase,
  446. message delivery occurs.
  447. If there were errors during processing
  448. during the second phase,
  449. .i sendmail
  450. creates and returns a new message describing the error
  451. and/or returns an status code
  452. telling what went wrong.
  453. .sh 3 "Argument processing and address parsing"
  454. .pp
  455. If
  456. .i sendmail
  457. is called using one of the two subprocess techniques,
  458. the arguments
  459. are first scanned
  460. and option specifications are processed.
  461. Recipient addresses are then collected,
  462. either from the command line
  463. or from the SMTP
  464. RCPT command,
  465. and a list of recipients is created.
  466. Aliases are expanded at this step,
  467. including mailing lists.
  468. As much validation as possible of the addresses
  469. is done at this step:
  470. syntax is checked, and local addresses are verified,
  471. but detailed checking of host names and addresses
  472. is deferred until delivery.
  473. Forwarding is also performed
  474. as the local addresses are verified.
  475. .pp
  476. .i Sendmail
  477. appends each address
  478. to the recipient list after parsing.
  479. When a name is aliased or forwarded,
  480. the old name is retained in the list,
  481. and a flag is set that tells the delivery phase
  482. to ignore this recipient.
  483. This list is kept free from duplicates,
  484. preventing alias loops
  485. and duplicate messages deliverd to the same recipient,
  486. as might occur if a person is in two groups.
  487. .sh 3 "Message collection"
  488. .pp
  489. .i Sendmail
  490. then collects the message.
  491. The message should have a header at the beginning.
  492. No formatting requirements are imposed on the message
  493. except that they must be lines of text
  494. (i.e., binary data is not allowed).
  495. The header is parsed and stored in memory,
  496. and the body of the message is saved
  497. in a temporary file.
  498. .pp
  499. To simplify the program interface,
  500. the message is collected even if no addresses were valid.
  501. The message will be returned with an error.
  502. .sh 3 "Message delivery"
  503. .pp
  504. For each unique mailer and host in the recipient list,
  505. .i sendmail
  506. calls the appropriate mailer.
  507. Each mailer invocation sends to all users receiving the message on one host.
  508. Mailers that only accept one recipient at a time
  509. are handled properly.
  510. .pp
  511. The message is sent to the mailer
  512. using one of the same three interfaces
  513. used to submit a message to sendmail.
  514. Each copy of the message is
  515. prepended by a customized header.
  516. The mailer status code is caught and checked,
  517. and a suitable error message given as appropriate.
  518. The exit code must conform to a system standard
  519. or a generic message
  520. (\c
  521. .q "Service unavailable" )
  522. is given.
  523. .sh 3 "Queueing for retransmission"
  524. .pp
  525. If the mailer returned an status that
  526. indicated that it might be able to handle the mail later,
  527. .i sendmail
  528. will queue the mail and try again later.
  529. .sh 3 "Return to sender"
  530. .pp
  531. If errors occur during processing,
  532. .i sendmail
  533. returns the message to the sender for retransmission.
  534. The letter can be mailed back
  535. or written in the file
  536. .q dead.letter
  537. in the sender's home directory\**.
  538. .(f
  539. \**Obviously, if the site giving the error is not the originating
  540. site, the only reasonable option is to mail back to the sender.
  541. Also, there are many more error disposition options,
  542. but they only effect the error message \*- the
  543. .q "return to sender"
  544. function is always handled in one of these two ways.
  545. .)f
  546. .sh 2 "Message Header Editing"
  547. .pp
  548. Certain editing of the message header
  549. occurs automatically.
  550. Header lines can be inserted
  551. under control of the configuration file.
  552. Some lines can be merged;
  553. for example,
  554. a
  555. .q From:
  556. line and a
  557. .q Full-name:
  558. line can be merged under certain circumstances.
  559. .sh 2 "Configuration File"
  560. .pp
  561. Almost all configuration information is read at runtime
  562. from an ASCII file,
  563. encoding
  564. macro definitions
  565. (defining the value of macros used internally),
  566. header declarations
  567. (telling sendmail the format of header lines that it will process specially,
  568. i.e., lines that it will add or reformat),
  569. mailer definitions
  570. (giving information such as the location and characteristics
  571. of each mailer),
  572. and address rewriting rules
  573. (a limited production system to rewrite addresses
  574. which is used to parse and rewrite the addresses).
  575. .pp
  576. To improve performance when reading the configuration file,
  577. a memory image can be provided.
  578. This provides a
  579. .q compiled
  580. form of the configuration file.
  581. .sh 1 "USAGE AND IMPLEMENTATION"
  582. .sh 2 "Arguments"
  583. .pp
  584. Arguments may be flags and addresses.
  585. Flags set various processing options.
  586. Following flag arguments,
  587. address arguments may be given,
  588. unless we are running in SMTP mode.
  589. Addresses follow the syntax in RFC822
  590. [Crocker82]
  591. for ARPANET
  592. address formats.
  593. In brief, the format is:
  594. .np
  595. Anything in parentheses is thrown away
  596. (as a comment).
  597. .np
  598. Anything in angle brackets (\c
  599. .q "<\|>" )
  600. is preferred
  601. over anything else.
  602. This rule implements the ARPANET standard that addresses of the form
  603. .(b
  604. user name <machine-address>
  605. .)b
  606. will send to the electronic
  607. .q machine-address
  608. rather than the human
  609. .q "user name."
  610. .np
  611. Double quotes
  612. (\ "\ )
  613. quote phrases;
  614. backslashes quote characters.
  615. Backslashes are more powerful
  616. in that they will cause otherwise equivalent phrases
  617. to compare differently \*- for example,
  618. .i user
  619. and
  620. .i
  621. "user"
  622. .r
  623. are equivalent,
  624. but
  625. .i \euser
  626. is different from either of them.
  627. .pp
  628. Parentheses, angle brackets, and double quotes
  629. must be properly balanced and nested.
  630. The rewriting rules control remaining parsing\**.
  631. .(f
  632. \**Disclaimer: Some special processing is done
  633. after rewriting local names; see below.
  634. .)f
  635. .sh 2 "Mail to Files and Programs"
  636. .pp
  637. Files and programs are legitimate message recipients.
  638. Files provide archival storage of messages,
  639. useful for project administration and history.
  640. Programs are useful as recipients in a variety of situations,
  641. for example,
  642. to maintain a public repository of systems messages
  643. (such as the Berkeley
  644. .i msgs
  645. program,
  646. or the MARS system
  647. [Sattley78]).
  648. .pp
  649. Any address passing through the initial parsing algorithm
  650. as a local address
  651. (i.e, not appearing to be a valid address for another mailer)
  652. is scanned for two special cases.
  653. If prefixed by a vertical bar (\c
  654. .q \^|\^ )
  655. the rest of the address is processed as a shell command.
  656. If the user name begins with a slash mark (\c
  657. .q /\^ )
  658. the name is used as a file name,
  659. instead of a login name.
  660. .pp
  661. Files that have setuid or setgid bits set
  662. but no execute bits set
  663. have those bits honored if
  664. .i sendmail
  665. is running as root.
  666. .sh 2 "Aliasing, Forwarding, Inclusion"
  667. .pp
  668. .i Sendmail
  669. reroutes mail three ways.
  670. Aliasing applies system wide.
  671. Forwarding allows each user to reroute incoming mail
  672. destined for that account.
  673. Inclusion directs
  674. .i sendmail
  675. to read a file for a list of addresses,
  676. and is normally used
  677. in conjunction with aliasing.
  678. .sh 3 "Aliasing"
  679. .pp
  680. Aliasing maps names to address lists using a system-wide file.
  681. This file is indexed to speed access.
  682. Only names that parse as local
  683. are allowed as aliases;
  684. this guarantees a unique key
  685. (since there are no nicknames for the local host).
  686. .sh 3 "Forwarding"
  687. .pp
  688. After aliasing,
  689. recipients that are local and valid
  690. are checked for the existence of a
  691. .q .forward
  692. file in their home directory.
  693. If it exists,
  694. the message is
  695. .i not
  696. sent to that user,
  697. but rather to the list of users in that file.
  698. Often
  699. this list will contain only one address,
  700. and the feature will be used for network mail forwarding.
  701. .pp
  702. Forwarding also permits a user to specify a private incoming mailer.
  703. For example,
  704. forwarding to:
  705. .(b
  706. "\^|\|/usr/local/newmail myname"
  707. .)b
  708. will use a different incoming mailer.
  709. .sh 3 "Inclusion"
  710. .pp
  711. Inclusion is specified in RFC 733 [Crocker77a] syntax:
  712. .(b
  713. :Include: pathname
  714. .)b
  715. An address of this form reads the file specified by
  716. .i pathname
  717. and sends to all users listed in that file.
  718. .pp
  719. The intent is
  720. .i not
  721. to support direct use of this feature,
  722. but rather to use this as a subset of aliasing.
  723. For example,
  724. an alias of the form:
  725. .(b
  726. project: :include:/usr/project/userlist
  727. .)b
  728. is a method of letting a project maintain a mailing list
  729. without interaction with the system administration,
  730. even if the alias file is protected.
  731. .pp
  732. It is not necessary to rebuild the index on the alias database
  733. when a :include: list is changed.
  734. .sh 2 "Message Collection"
  735. .pp
  736. Once all recipient addresses are parsed and verified,
  737. the message is collected.
  738. The message comes in two parts:
  739. a message header and a message body,
  740. separated by a blank line.
  741. .pp
  742. The header is formatted as a series of lines
  743. of the form
  744. .(b
  745.     field-name: field-value
  746. .)b
  747. Field-value can be split across lines by starting the following
  748. lines with a space or a tab.
  749. Some header fields have special internal meaning,
  750. and have appropriate special processing.
  751. Other headers are simply passed through.
  752. Some header fields may be added automatically,
  753. such as time stamps.
  754. .pp
  755. The body is a series of text lines.
  756. It is completely uninterpreted and untouched,
  757. except that lines beginning with a dot
  758. have the dot doubled
  759. when transmitted over an SMTP channel.
  760. This extra dot is stripped by the receiver.
  761. .sh 2 "Message Delivery"
  762. .pp
  763. The send queue is ordered by receiving host
  764. before transmission
  765. to implement message batching.
  766. Each address is marked as it is sent
  767. so rescanning the list is safe.
  768. An argument list is built as the scan proceeds.
  769. Mail to files is detected during the scan of the send list.
  770. The interface to the mailer
  771. is performed using one of the techniques
  772. described in section 2.2.
  773. .pp
  774. After a connection is established,
  775. .i sendmail
  776. makes the per-mailer changes to the header
  777. and sends the result to the mailer.
  778. If any mail is rejected by the mailer,
  779. a flag is set to invoke the return-to-sender function
  780. after all delivery completes.
  781. .sh 2 "Queued Messages"
  782. .pp
  783. If the mailer returns a
  784. .q "temporary failure"
  785. exit status,
  786. the message is queued.
  787. A control file is used to describe the recipients to be sent to
  788. and various other parameters.
  789. This control file is formatted as a series of lines,
  790. each describing a sender,
  791. a recipient,
  792. the time of submission,
  793. or some other salient parameter of the message.
  794. The header of the message is stored
  795. in the control file,
  796. so that the associated data file in the queue
  797. is just the temporary file that was originally collected.
  798. .sh 2 "Configuration"
  799. .pp
  800. Configuration is controlled primarily by a configuration file
  801. read at startup.
  802. .i Sendmail
  803. should not need to be recomplied except
  804. .np
  805. To change operating systems
  806. (V6, V7/32V, 4BSD).
  807. .np
  808. To remove or insert the DBM
  809. (UNIX database)
  810. library.
  811. .np
  812. To change ARPANET reply codes.
  813. .np
  814. To add headers fields requiring special processing.
  815. .lp
  816. Adding mailers or changing parsing
  817. (i.e., rewriting)
  818. or routing information
  819. does not require recompilation.
  820. .pp
  821. If the mail is being sent by a local user,
  822. and the file
  823. .q .mailcf
  824. exists in the sender's home directory,
  825. that file is read as a configuration file
  826. after the system configuration file.
  827. The primary use of this feature is to add header lines.
  828. .pp
  829. The configuration file encodes macro definitions,
  830. header definitions,
  831. mailer definitions,
  832. rewriting rules,
  833. and options.
  834. .sh 3 Macros
  835. .pp
  836. Macros can be used in three ways.
  837. Certain macros transmit
  838. unstructured textual information
  839. into the mail system,
  840. such as the name
  841. .i sendmail
  842. will use to identify itself in error messages.
  843. Other macros transmit information from
  844. .i sendmail
  845. to the configuration file
  846. for use in creating other fields
  847. (such as argument vectors to mailers);
  848. e.g., the name of the sender,
  849. and the host and user
  850. of the recipient.
  851. Other macros are unused internally,
  852. and can be used as shorthand in the configuration file.
  853. .sh 3 "Header declarations"
  854. .pp
  855. Header declarations inform
  856. .i sendmail
  857. of the format of known header lines.
  858. Knowledge of a few header lines
  859. is built into
  860. .i sendmail ,
  861. such as the
  862. .q From:
  863. and
  864. .q Date:
  865. lines.
  866. .pp
  867. Most configured headers
  868. will be automatically inserted
  869. in the outgoing message
  870. if they don't exist in the incoming message.
  871. Certain headers are suppressed by some mailers.
  872. .sh 3 "Mailer declarations"
  873. .pp
  874. Mailer declarations tell
  875. .i sendmail
  876. of the various mailers available to it.
  877. The definition specifies the internal name of the mailer,
  878. the pathname of the program to call,
  879. some flags associated with the mailer,
  880. and an argument vector to be used on the call;
  881. this vector is macro-expanded before use.
  882. .sh 3 "Address rewriting rules"
  883. .pp
  884. The heart of address parsing in
  885. .i sendmail
  886. is a set of rewriting rules.
  887. These are an ordered list of pattern-replacement rules,
  888. (somewhat like a production system,
  889. except that order is critical),
  890. which are applied to each address.
  891. The address is rewritten textually until it is either rewritten
  892. into a special canonical form
  893. (i.e.,
  894. a (mailer, host, user)
  895. 3-tuple,
  896. such as {arpanet, usc-isif, postel}
  897. representing the address
  898. .q "postel@usc-isif" ),
  899. or it falls off the end.
  900. When a pattern matches,
  901. the rule is reapplied until it fails.
  902. .pp
  903. The configuration file also supports the editing of addresses
  904. into different formats.
  905. For example,
  906. an address of the form:
  907. .(b
  908. ucsfcgl!tef
  909. .)b
  910. might be mapped into:
  911. .(b
  912. tef@ucsfcgl.UUCP
  913. .)b
  914. to conform to the domain syntax.
  915. Translations can also be done in the other direction.
  916. .sh 3 "Option setting"
  917. .pp
  918. There are several options that can be set
  919. from the configuration file.
  920. These include the pathnames of various support files,
  921. timeouts,
  922. default modes,
  923. etc.
  924. .sh 1 "COMPARISON WITH OTHER MAILERS"
  925. .sh 2 "Delivermail"
  926. .pp
  927. .i Sendmail
  928. is an outgrowth of
  929. .i delivermail .
  930. The primary differences are:
  931. .np
  932. Configuration information is not compiled in.
  933. This change simplifies many of the problems
  934. of moving to other machines.
  935. It also allows easy debugging of new mailers.
  936. .np
  937. Address parsing is more flexible.
  938. For example,
  939. .i delivermail
  940. only supported one gateway to any network,
  941. whereas
  942. .i sendmail
  943. can be sensitive to host names
  944. and reroute to different gateways.
  945. .np
  946. Forwarding and
  947. :include:
  948. features eliminate the requirement that the system alias file
  949. be writable by any user
  950. (or that an update program be written,
  951. or that the system administration make all changes).
  952. .np
  953. .i Sendmail
  954. supports message batching across networks
  955. when a message is being sent to multiple recipients.
  956. .np
  957. A mail queue is provided in
  958. .i sendmail.
  959. Mail that cannot be delivered immediately
  960. but can potentially be delivered later
  961. is stored in this queue for a later retry.
  962. The queue also provides a buffer against system crashes;
  963. after the message has been collected
  964. it may be reliably redelivered
  965. even if the system crashes during the initial delivery.
  966. .np
  967. .i Sendmail
  968. uses the networking support provided by 4.2BSD
  969. to provide a direct interface networks such as the ARPANET
  970. and/or Ethernet
  971. using SMTP (the Simple Mail Transfer Protocol)
  972. over a TCP/IP connection.
  973. .sh 2 "MMDF"
  974. .pp
  975. MMDF
  976. [Crocker79]
  977. spans a wider problem set than
  978. .i sendmail .
  979. For example,
  980. the domain of
  981. MMDF includes a
  982. .q "phone network"
  983. mailer, whereas
  984. .i sendmail
  985. calls on preexisting mailers in most cases.
  986. .pp
  987. MMDF and
  988. .i sendmail
  989. both support aliasing,
  990. customized mailers,
  991. message batching,
  992. automatic forwarding to gateways,
  993. queueing,
  994. and retransmission.
  995. MMDF supports two-stage timeout,
  996. which
  997. .i sendmail
  998. does not support.
  999. .pp
  1000. The configuration for MMDF
  1001. is compiled into the code\**.
  1002. .(f
  1003. \**Dynamic configuration tables are currently being considered
  1004. for MMDF;
  1005. allowing the installer to select either compiled
  1006. or dynamic tables.
  1007. .)f
  1008. .pp
  1009. Since MMDF does not consider backwards compatibility
  1010. as a design goal,
  1011. the address parsing is simpler but much less flexible.
  1012. .pp
  1013. It is somewhat harder to integrate a new channel\**
  1014. .(f
  1015. \**The MMDF equivalent of a
  1016. .i sendmail
  1017. .q mailer.
  1018. .)f
  1019. into MMDF.
  1020. In particular,
  1021. MMDF must know the location and format
  1022. of host tables for all channels,
  1023. and the channel must speak a special protocol.
  1024. This allows MMDF to do additional verification
  1025. (such as verifying host names)
  1026. at submission time.
  1027. .pp
  1028. MMDF strictly separates the submission and delivery phases.
  1029. Although
  1030. .i sendmail
  1031. has the concept of each of these stages,
  1032. they are integrated into one program,
  1033. whereas in MMDF they are split into two programs.
  1034. .sh 2 "Message Processing Module"
  1035. .pp
  1036. The Message Processing Module (MPM)
  1037. discussed by Postel [Postel79b]
  1038. matches
  1039. .i sendmail
  1040. closely in terms of its basic architecture.
  1041. However,
  1042. like MMDF,
  1043. the MPM includes the network interface software
  1044. as part of its domain.
  1045. .pp
  1046. MPM also postulates a duplex channel to the receiver,
  1047. as does MMDF,
  1048. thus allowing simpler handling of errors
  1049. by the mailer
  1050. than is possible in
  1051. .i sendmail .
  1052. When a message queued by
  1053. .i sendmail
  1054. is sent,
  1055. any errors must be returned to the sender
  1056. by the mailer itself.
  1057. Both MPM and MMDF mailers
  1058. can return an immediate error response,
  1059. and a single error processor can create an appropriate response.
  1060. .pp
  1061. MPM prefers passing the message as a structured object,
  1062. with type-length-value tuples\**.
  1063. .(f
  1064. \**This is similar to the NBS standard.
  1065. .)f
  1066. Such a convention requires a much higher degree of cooperation
  1067. between mailers than is required by
  1068. .i sendmail .
  1069. MPM also assumes a universally agreed upon internet name space
  1070. (with each address in the form of a net-host-user tuple),
  1071. which
  1072. .i sendmail
  1073. does not.
  1074. .sh 1 "EVALUATIONS AND FUTURE PLANS"
  1075. .pp
  1076. .i Sendmail
  1077. is designed to work in a nonhomogeneous environment.
  1078. Every attempt is made to avoid imposing unnecessary constraints
  1079. on the underlying mailers.
  1080. This goal has driven much of the design.
  1081. One of the major problems
  1082. has been the lack of a uniform address space,
  1083. as postulated in [Postel79a]
  1084. and [Postel79b].
  1085. .pp
  1086. A nonuniform address space implies that a path will be specified
  1087. in all addresses,
  1088. either explicitly (as part of the address)
  1089. or implicitly
  1090. (as with implied forwarding to gateways).
  1091. This restriction has the unpleasant effect of making replying to messages
  1092. exceedingly difficult,
  1093. since there is no one
  1094. .q address
  1095. for any person,
  1096. but only a way to get there from wherever you are.
  1097. .pp
  1098. Interfacing to mail programs
  1099. that were not initially intended to be applied
  1100. in an internet environment
  1101. has been amazingly successful,
  1102. and has reduced the job to a manageable task.
  1103. .pp
  1104. .i Sendmail
  1105. has knowledge of a few difficult environments
  1106. built in.
  1107. It generates ARPANET FTP/SMTP compatible error messages
  1108. (prepended with three-digit numbers
  1109. [Neigus73, Postel74, Postel82])
  1110. as necessary,
  1111. optionally generates UNIX-style
  1112. .q From
  1113. lines on the front of messages for some mailers,
  1114. and knows how to parse the same lines on input.
  1115. Also,
  1116. error handling has an option customized for BerkNet.
  1117. .pp
  1118. The decision to avoid doing any type of delivery where possible
  1119. (even, or perhaps especially, local delivery)
  1120. has turned out to be a good idea.
  1121. Even with local delivery,
  1122. there are issues of the location of the mailbox,
  1123. the format of the mailbox,
  1124. the locking protocol used,
  1125. etc.,
  1126. that are best decided by other programs.
  1127. One surprisingly major annoyance in many internet mailers
  1128. is that the location and format of local mail is built in.
  1129. The feeling seems to be that local mail is so common
  1130. that it should be efficient.
  1131. This feeling is not born out by
  1132. our experience;
  1133. on the contrary,
  1134. the location and format of mailboxes seems to vary widely
  1135. from system to system.
  1136. .pp
  1137. The ability to automatically generate a response to incoming mail
  1138. (by forwarding mail to a program)
  1139. seems useful
  1140. (\c
  1141. .q "I am on vacation until late August...." )
  1142. but can create problems
  1143. such as forwarding loops
  1144. (two people on vacation whose programs send notes back and forth,
  1145. for instance)
  1146. if these programs are not well written.
  1147. A program could be written to do standard tasks correctly,
  1148. but this would solve the general case.
  1149. .pp
  1150. It might be desirable to implement some form of load limiting.
  1151. I am unaware of any mail system that addresses this problem,
  1152. nor am I aware of any reasonable solution at this time.
  1153. .pp
  1154. The configuration file is currently practically inscrutable;
  1155. considerable convenience could be realized
  1156. with a higher-level format.
  1157. .pp
  1158. It seems clear that common protocols will be changing soon
  1159. to accommodate changing requirements and environments.
  1160. These changes will include modifications to the message header
  1161. (e.g., [NBS80])
  1162. or to the body of the message itself
  1163. (such as for multimedia messages
  1164. [Postel80]).
  1165. Experience indicates that
  1166. these changes should be relatively trivial to integrate
  1167. into the existing system.
  1168. .pp
  1169. In tightly coupled environments,
  1170. it would be nice to have a name server
  1171. such as Grapvine
  1172. [Birrell82]
  1173. integrated into the mail system.
  1174. This would allow a site such as
  1175. .q Berkeley
  1176. to appear as a single host,
  1177. rather than as a collection of hosts,
  1178. and would allow people to move transparently among machines
  1179. without having to change their addresses.
  1180. Such a facility
  1181. would require an automatically updated database
  1182. and some method of resolving conflicts.
  1183. Ideally this would be effective even without
  1184. all hosts being under
  1185. a single management.
  1186. However,
  1187. it is not clear whether this feature
  1188. should be integrated into the
  1189. aliasing facility
  1190. or should be considered a
  1191. .q "value added"
  1192. feature outside
  1193. .i sendmail
  1194. itself.
  1195. .pp
  1196. As a more interesting case,
  1197. the CSNET name server
  1198. [Solomon81]
  1199. provides an facility that goes beyond a single
  1200. tightly-coupled environment.
  1201. Such a facility would normally exist outside of
  1202. .i sendmail
  1203. however.
  1204. .sh 0 "ACKNOWLEDGEMENTS"
  1205. .pp
  1206. Thanks are due to Kurt Shoens for his continual cheerful
  1207. assistance and good advice,
  1208. Bill Joy for pointing me in the correct direction
  1209. (over and over),
  1210. and Mark Horton for more advice,
  1211. prodding,
  1212. and many of the good ideas.
  1213. Kurt and Eric Schmidt are to be credited
  1214. for using
  1215. .i delivermail
  1216. as a server for their programs
  1217. (\c
  1218. .i Mail
  1219. and BerkNet respectively)
  1220. before any sane person should have,
  1221. and making the necessary modifications
  1222. promptly and happily.
  1223. Eric gave me considerable advice about the perils
  1224. of network software which saved me an unknown
  1225. amount of work and grief.
  1226. Mark did the original implementation of the DBM version
  1227. of aliasing, installed the VFORK code,
  1228. wrote the current version of
  1229. .i rmail ,
  1230. and was the person who really convinced me
  1231. to put the work into
  1232. .i delivermail
  1233. to turn it into
  1234. .i sendmail .
  1235. Kurt deserves accolades for using
  1236. .i sendmail
  1237. when I was myself afraid to take the risk;
  1238. how a person can continue to be so enthusiastic
  1239. in the face of so much bitter reality is beyond me.
  1240. .pp
  1241. Kurt,
  1242. Mark,
  1243. Kirk McKusick,
  1244. Marvin Solomon,
  1245. and many others have reviewed this paper,
  1246. giving considerable useful advice.
  1247. .pp
  1248. Special thanks are reserved for Mike Stonebraker at Berkeley
  1249. and Bob Epstein at Britton-Lee,
  1250. who both knowingly allowed me to put so much work into this
  1251. project
  1252. when there were so many other things I really should
  1253. have been working on.
  1254. .+c
  1255. .ce
  1256. REFERENCES
  1257. .nr ii 1.5i
  1258. .ip [Birrell82]
  1259. Birrell, A. D.,
  1260. Levin, R.,
  1261. Needham, R. M.,
  1262. and
  1263. Schroeder, M. D.,
  1264. .q "Grapevine: An Exercise in Distributed Computing."
  1265. In
  1266. .ul
  1267. Comm. A.C.M. 25,
  1268. 4,
  1269. April 82.
  1270. .ip [Borden79]
  1271. Borden, S.,
  1272. Gaines, R. S.,
  1273. and
  1274. Shapiro, N. Z.,
  1275. .ul
  1276. The MH Message Handling System: Users' Manual.
  1277. R-2367-PAF.
  1278. Rand Corporation.
  1279. October 1979.
  1280. .ip [Crocker77a]
  1281. Crocker, D. H.,
  1282. Vittal, J. J.,
  1283. Pogran, K. T.,
  1284. and
  1285. Henderson, D. A. Jr.,
  1286. .ul
  1287. Standard for the Format of ARPA Network Text Messages.
  1288. RFC 733,
  1289. NIC 41952.
  1290. In [Feinler78].
  1291. November 1977.
  1292. .ip [Crocker77b]
  1293. Crocker, D. H.,
  1294. .ul
  1295. Framework and Functions of the MS Personal Message System.
  1296. R-2134-ARPA,
  1297. Rand Corporation,
  1298. Santa Monica, California.
  1299. 1977.
  1300. .ip [Crocker79]
  1301. Crocker, D. H.,
  1302. Szurkowski, E. S.,
  1303. and
  1304. Farber, D. J.,
  1305. .ul
  1306. An Internetwork Memo Distribution Facility \*- MMDF.
  1307. 6th Data Communication Symposium,
  1308. Asilomar.
  1309. November 1979.
  1310. .ip [Crocker82]
  1311. Crocker, D. H.,
  1312. .ul
  1313. Standard for the Format of Arpa Internet Text Messages.
  1314. RFC 822.
  1315. Network Information Center,
  1316. SRI International,
  1317. Menlo Park, California.
  1318. August 1982.
  1319. .ip [Metcalfe76]
  1320. Metcalfe, R.,
  1321. and
  1322. Boggs, D.,
  1323. .q "Ethernet: Distributed Packet Switching for Local Computer Networks" ,
  1324. .ul
  1325. Communications of the ACM 19,
  1326. 7.
  1327. July 1976.
  1328. .ip [Feinler78]
  1329. Feinler, E.,
  1330. and
  1331. Postel, J.
  1332. (eds.),
  1333. .ul
  1334. ARPANET Protocol Handbook.
  1335. NIC 7104,
  1336. Network Information Center,
  1337. SRI International,
  1338. Menlo Park, California.
  1339. 1978.
  1340. .ip [NBS80]
  1341. National Bureau of Standards,
  1342. .ul
  1343. Specification of a Draft Message Format Standard.
  1344. Report No. ICST/CBOS 80-2.
  1345. October 1980.
  1346. .ip [Neigus73]
  1347. Neigus, N.,
  1348. .ul
  1349. File Transfer Protocol for the ARPA Network.
  1350. RFC 542, NIC 17759.
  1351. In [Feinler78].
  1352. August, 1973.
  1353. .ip [Nowitz78a]
  1354. Nowitz, D. A.,
  1355. and
  1356. Lesk, M. E.,
  1357. .ul
  1358. A Dial-Up Network of UNIX Systems.
  1359. Bell Laboratories.
  1360. In
  1361. UNIX Programmer's Manual, Seventh Edition,
  1362. Volume 2.
  1363. August, 1978.
  1364. .ip [Nowitz78b]
  1365. Nowitz, D. A.,
  1366. .ul
  1367. Uucp Implementation Description.
  1368. Bell Laboratories.
  1369. In
  1370. UNIX Programmer's Manual, Seventh Edition,
  1371. Volume 2.
  1372. October, 1978.
  1373. .ip [Postel74]
  1374. Postel, J.,
  1375. and
  1376. Neigus, N.,
  1377. Revised FTP Reply Codes.
  1378. RFC 640, NIC 30843.
  1379. In [Feinler78].
  1380. June, 1974.
  1381. .ip [Postel77]
  1382. Postel, J.,
  1383. .ul
  1384. Mail Protocol.
  1385. NIC 29588.
  1386. In [Feinler78].
  1387. November 1977.
  1388. .ip [Postel79a]
  1389. Postel, J.,
  1390. .ul
  1391. Internet Message Protocol.
  1392. RFC 753,
  1393. IEN 85.
  1394. Network Information Center,
  1395. SRI International,
  1396. Menlo Park, California.
  1397. March 1979.
  1398. .ip [Postel79b]
  1399. Postel, J. B.,
  1400. .ul
  1401. An Internetwork Message Structure.
  1402. In
  1403. .ul
  1404. Proceedings of the Sixth Data Communications Symposium,
  1405. IEEE.
  1406. New York.
  1407. November 1979.
  1408. .ip [Postel80]
  1409. Postel, J. B.,
  1410. .ul
  1411. A Structured Format for Transmission of Multi-Media Documents.
  1412. RFC 767.
  1413. Network Information Center,
  1414. SRI International,
  1415. Menlo Park, California.
  1416. August 1980.
  1417. .ip [Postel82]
  1418. Postel, J. B.,
  1419. .ul
  1420. Simple Mail Transfer Protocol.
  1421. RFC821
  1422. (obsoleting RFC788).
  1423. Network Information Center,
  1424. SRI International,
  1425. Menlo Park, California.
  1426. August 1982.
  1427. .ip [Schmidt79]
  1428. Schmidt, E.,
  1429. .ul
  1430. An Introduction to the Berkeley Network.
  1431. University of California, Berkeley California.
  1432. 1979.
  1433. .ip [Shoens79]
  1434. Shoens, K.,
  1435. .ul
  1436. Mail Reference Manual.
  1437. University of California, Berkeley.
  1438. In UNIX Programmer's Manual,
  1439. Seventh Edition,
  1440. Volume 2C.
  1441. December 1979.
  1442. .ip [Sluizer81]
  1443. Sluizer, S.,
  1444. and
  1445. Postel, J. B.,
  1446. .ul
  1447. Mail Transfer Protocol.
  1448. RFC 780.
  1449. Network Information Center,
  1450. SRI International,
  1451. Menlo Park, California.
  1452. May 1981.
  1453. .ip [Solomon81]
  1454. Solomon, M., Landweber, L., and Neuhengen, D.,
  1455. .q "The Design of the CSNET Name Server."
  1456. CS-DN-2,
  1457. University of Wisconsin, Madison.
  1458. November 1981.
  1459. .ip [Su82]
  1460. Su, Zaw-Sing,
  1461. and
  1462. Postel, Jon,
  1463. .ul
  1464. The Domain Naming Convention for Internet User Applications.
  1465. RFC819.
  1466. Network Information Center,
  1467. SRI International,
  1468. Menlo Park, California.
  1469. August 1982.
  1470. .ip [UNIX83]
  1471. .ul
  1472. The UNIX Programmer's Manual, Seventh Edition,
  1473. Virtual VAX-11 Version,
  1474. Volume 1.
  1475. Bell Laboratories,
  1476. modified by the University of California,
  1477. Berkeley, California.
  1478. March, 1983.
  1479.