1.nr DR 1	\" this is a draft copy
2.nr si 3n
3.he 'SENDMAIL''%'
4.if \n(DR .fo 'For Your Eyes Only'\*-DRAFT\*-'\*(td'
5.ls 2
6.+c
7.(l C
8.sz 14
9SENDMAIL \*- An Internet Mail Router
10.sz
11.sp
12Eric Allman
13.sp 0.5
14.i
15Project INGRES
16Electronics Research Lab
17University of California
18Berkeley, California  94720
19.)l
20.sp 2
21.(f
22This is
23.if \n(DR draft
24version 3.8,
25last modified on 09/09/81.
26.if \n(DR Please do not distribute this version without permission
27.if \n(DR of the author.
28.)f
29.pp
30.i Sendmail
31implements a general internetwork mail routing facility,
32featuring aliasing and forwarding,
33automatic routing to network gateways,
34and flexible configuration.
35.pp
36Section 1 discusses the design goals for
37.i sendmail .
38Section 2 gives an overview of the basic functions of the system.
39In section 3,
40details of usage are discussed.
41A detailed description of the configuration file
42is given in section 4,
43including a walkthrough of a specific configuration file.
44Section 5 compares
45.i sendmail
46to other internet mail routers,
47and an evaluation of
48.i sendmail
49is given in section 6,
50including future plans.
51.sh 1 "DESIGN GOALS"
52.pp
53.i Sendmail
54was an outgrowth of
55.i delivermail,
56a previous incarnation of a UNIX internetwork mail router.
57.i Delivermail
58was written relatively quickly.
59The first version only knew about taking apart addresses
60for explicit forwarding
61and limited aliasing;
62automatic forwarding and other features
63came later.
64.pp
65Design goals for
66.i delivermail
67included:
68.np
69Compatibility with the existing mail system,
70including Bell version 6 mail,
71Bell version 7 mail
72[UNIX80],
73Berkeley
74.i Mail
75[Shoens79],
76BerkNet mail
77[Schmidt79],
78and hopefully UUCP mail
79[Nowitz78a, Nowitz78b].
80ARPANET mail
81[Crocker77a, Postel77]
82was also required,
83and the difference in format
84influenced the decision to put all such formatting
85into the low-level mailer.
86.np
87Because of time constraints,
88utilize as much existing software as possible.
89The changes to the existing software were minimal:
90Berkeley mail,
91BerkNet,
92UUCP, and the ARPANET FTP server
93were modified to call
94.i delivermail
95as their server instead of
96/bin/mail
97(or in the case of the ARPANET,
98instead of
99writing the mail into a file
100which has no meaning to standard UNIX mailers).
101The only major modifications
102were to /bin/mail,
103which was maintained both as a user interface sender
104and as a
105.i delivermail
106mailer.
107As a sender,
108it calls
109.i delivermail .
110.i Delivermail
111calls it in turn to do local delivery,
112so a
113.b \-d
114flag was added to avoid loops.
115.np
116Reliability was considered essential
117because of the emphasis on mail in our environment.
118This turned out to be one of the hardest goals to satisfy,
119especially in the face of the many anomalous message formats
120produced by various ARPANET sites.
121For example,
122MIT and CMU allow mail from people who are not logged in
123(and which have meaningless from addresses),
124which caused error message loops.
125CMU also puts blanks in names,
126which created amazing problems,
127since many UNIX mail programs assume that an address
128is one word.
129And at least one person lists his address as
130.q "From: the TTY of ..." ,
131giving a
132.q Sender:
133field with his real address.
134In summary,
135the obscure aspects of the ARPANET mail protocol
136really
137.i are
138used and
139are difficult to support,
140but must be supported.
141But even obeying the standard is insufficient.
142For example,
143WHARTON changes our host name from
144.q BERKELEY
145to
146.q BERKEL- ,
147which confused error processing.
148Degenerate cases such as this
149must be handled gracefully.
150.pp
151There were certain non-goals in
152.i delivermail
153also.
154Many of these resulted from the expectation that
155it would only be used at Berkeley,
156and probably only at a few sites at Berkeley.
157.np
158It was fair game to compile configuration information
159into the code,
160even to assume that they were running BerkNet.
161.np
162The problem of multiple connections to a single network
163was not foreseen.
164For example,
165on a host with no UUCP connection,
166all UUCP mail was sent to a single host.
167In fact,
168Berkeley is running UUCP on at least three hosts.
169.np
170No attempt was made to reduce the volume of mail across a network link.
171Besides the difficulty of doing this,
172we failed to appreciate how much volume there would be.
173.np
174Existing software to do actual delivery
175should be used whenever possible.
176This resulted as much from political and practical considerations
177as technical.
178.pp
179.i Sendmail
180maintained the goals of
181.i delivermail.
182Time was less of a constraint,
183but not reimplementing basic mailers
184has proven to be a wise move in many ways.
185For example,
186many internet mailers deliver local mail directly.
187This is more efficient,
188but builds in the design decisions
189of the local mailer,
190and makes it difficult to concentrate
191on the
192.q "real problems"
193(such as locking).
194Other design goals were:
195.np
196.i Sendmail
197should operate in more complex environments,
198including multiple
199connections to a single network type
200(such as with multiple UUCP or Ether nets
201[Metcalfe76]),
202requiring that the contents of a host field
203be considered,
204as well as just the syntax of an address,
205in order to determine the gateway to use.
206This results both from a desire to simplify use by other sites,
207and to anticipate the environment Berkeley is moving towards.
208.np
209Configuration should not be compiled into the code.
210A single binary should be able to run as is at any site
211(modulo such basic changes as the CPU type or the operating system).
212We have found this seemingly unimportant goal
213to be critical in real life.
214Besides the simple problems that occur when any program gets recompiled
215in a different environment,
216many sites like to
217.q fiddle
218with anything that they will be recompiling anyway.
219.np
220.i Delivermail
221only knows about one alias file
222and per-user forwarding is unsupported.
223Berkeley is a sufficiently open environment
224that this can be writable by everyone,
225but other environments are not so lax.
226Thus,
227.i sendmail
228must be able to let various groups maintain their own mailing lists,
229and individuals their own forwarding,
230without writing the system alias file.
231.np
232Customized incoming mailers should be supported.
233This allows users who are using specialized mailers
234that want to use a different format to build their environment
235without changing the system,
236and allows specialized functions
237(such as returning an
238.q "I am on vacation"
239message).
240.np
241Network traffic should be minimized
242by batching addresses to a single host where possible,
243without assistance by the user.
244.sh 1 "OVERVIEW"
245.sh 2 "System Organization"
246.pp
247.i Sendmail
248neither interfaces with the user
249nor does actual mail delivery.
250Rather,
251it collects a message
252generated by a user interface program (UIP)
253such as Berkeley
254.i Mail ,
255MS
256[Crocker77b],
257or MH
258[Borden79],
259edits the message as required by the destination network,
260and calls appropriate mailers
261to do mail delivery or queueing for network transmission
262(the exception is when mailing to a file).
263This discipline allows the insertion of new mailers
264at minimum cost.
265In this sense
266.i sendmail
267resembles the Message Processing Module (MPM)
268of [Postel79b].
269See Figure 1.
270.(z
271.hl
272.ie t \
273.	sp 18
274.el \{\
275.(c
276	       +-------+
277	       | user  |
278	       +-------+
279		   |
280	        +-----+
281	        | UIP |
282	        +-----+
283		   |
284             +-----------+
285             | sendmail  |
286             +-----------+
287		|  |  |
288     +----------+  +  +----------+
289     |  	   |             |
290+---------+   +---------+   +---------+
291| mailer1 |   | mailer2 |   | mailer3 |
292+---------+   +---------+   +---------+
293.)c
294.\}
295
296.ce
297Figure 1 \*- System Structure.
298.hl
299.)z
300.sh 2 "Operational Description"
301.sh 3 "Argument processing and address parsing"
302.pp
303The arguments are first scanned,
304and flag arguments processed.
305The remaining arguments are
306parsed in turn as addresses,
307and a list of recipients is created.
308Aliases are expanded at this step.
309As much validation of the addresses as possible
310is done at this step:
311syntax is checked, and local addresses are verified,
312but detailed checking of host names and addresses
313is deferred until delivery.
314Forwarding is also performed
315as the local addresses are verified.
316.pp
317.i Sendmail
318appends each address
319to the recipient list after parsing.
320When a name is aliased or forwarded,
321the old name is retained in the list,
322and a flag is set in the address header
323that tells the delivery phase
324to ignore this recipient.
325This list is kept without duplicates,
326preventing alias loops
327and eliminating people receiving two copies of a message,
328as might occur if a person were in two groups.
329.sh 3 "Message collection"
330.pp
331.i Sendmail
332then collects the message from the standard input.
333The message header is parsed at this point.
334The header is stored in memory,
335and the body of the message is saved
336in a temporary file.
337.pp
338Collection occurs even if no addresses were valid
339to simplify program interface.
340The message will be returned with an error.
341.sh 3 "Message delivery"
342.pp
343For each unique mailer and host in the send list,
344.i sendmail
345calls the appropriate mailer.
346Each call contains the users on that host.
347Mailers that only accept one recipient at a time
348are handled properly.
349.pp
350The message is sent to the mailer
351(which must read its standard input)
352prepended by a customized header.
353The mailer exit code is caught and checked,
354and a suitable error message given as appropriate.
355The exit code must conform to a system standard
356or a meaningless message
357(\c
358.q "Service unavailable" )
359is given.
360.pp
361Delivery to files executes directly.
362.sh 3 "Return to sender"
363.pp
364If errors occurred during processing,
365.i sendmail
366returns the message to the sender for retransmission.
367The letter can be mailed back
368or written in the file
369.q dead.letter
370in the sender's home directory\**.
371.(f
372\**Obviously, if the site giving the error is not the originating
373site, the only reasonable option is to mail back to the sender.
374Also, there are many more error disposition options,
375but they only effect the error message \*- the
376.q "return to sender"
377function is always handled in one of these two ways.
378.)f
379.sh 2 "Configuration File"
380.pp
381Almost all configuration information is read at runtime
382from an ASCII file,
383encoding
384macro definitions,
385header declarations,
386mailer definitions,
387and address rewriting rules.
388.sh 3 Macros
389.pp
390Macros can be used in three ways.
391Certain macros transmit
392unstructured textual information
393into the mail system,
394such as the name
395.i sendmail
396will use to identify itself in error messages.
397Other macros transmit information from
398.i sendmail
399to the configuration file
400for use in creating other fields
401(such as argument vectors to mailers);
402e.g., the name of the sender,
403and the host and user
404of the recipient.
405Other macros are unused internally,
406and can be used as shorthand in the configuration file.
407.sh 3 "Header declarations"
408.pp
409Header declarations inform
410.i sendmail
411of the format of known header lines.
412Knowledge of a few header lines
413is built into
414.i sendmail ,
415such as the
416.q From:
417and
418.q Date:
419lines.
420.pp
421Most configured headers
422will be automatically inserted
423in the outgoing message
424if they don't exist in the incoming message.
425Certain headers are suppressed by some mailers.
426.sh 3 "Mailer declarations"
427.pp
428Mailer declarations tell
429.i sendmail
430of the various mailers available to it.
431The definition specifies the internal name of the mailer,
432the pathname of the program to call,
433some flags associated with the mailer,
434and an argument vector to be used on the call;
435this vector is macro expanded before use.
436.sh 3 "Address rewriting rules"
437.pp
438The heart of address parsing in
439.i sendmail
440is a set of rewriting rules.
441These are an ordered list of pattern-replacement rules,
442somewhat like a production system,
443except that order is critical.
444Each address is applied successively to these rules
445being rewritten into a different (textual) form
446until it resolves into a canonical address
447(i.e.,
448a [mailer, host, user]
4493-tuple),
450or it falls off the end.
451When a pattern matches,
452the rule is reapplied until it fails.
453.sh 2 "Message Header Editing"
454.pp
455Certain editing of the message header
456occurs automatically.
457Header lines can be inserted
458under control of the configuration file.
459Some lines can be merged;
460for example,
461a
462.q From:
463line and a
464.q Full-name:
465line can be merged under certain circumstances.
466.sh 1 "USAGE AND IMPLEMENTATION"
467.sh 2 "Arguments"
468.pp
469Arguments may be flags and addresses.
470The flag arguments are described in Appendix A.
471Following flag arguments,
472address arguments may be given.
473These follow the syntax in RFC733
474[Crocker77a]
475for ARPANET
476address formats.
477In brief, the format is:
478.np
479Anything in parentheses is thrown away
480(as a comment).
481.np
482Anything in angle brackets (\ <>\ ) is preferred
483over anything else.
484.np
485Double quotes
486(\ "\ )
487quote phrases;
488backslashes quote characters.
489Backslashes are more powerful \*- for example,
490.i user
491and
492.i
493"user"
494.r
495are equivalent,
496but
497.i \euser
498is different from either of them.
499.pp
500The rewriting rules control remaining parsing
501(disclaimer: some special processing is done
502after rewriting local names; see below).
503Parentheses, angle brackets, and double quotes
504must be properly balanced and nested.
505.sh 2 "Mail to Files and Programs"
506.pp
507Files and programs are legitimate message recipients.
508Files provide archival storage of messages,
509useful for project administration and history.
510Programs are useful as recipients in a variety of situations,
511for example,
512as a public repository of systems messages
513(such as the Berkeley
514.i msgs
515program,
516or the MARS system
517[Sattley78]).
518.pp
519Any address passing through the initial parsing algorithm
520as a local address
521(i.e, not appearing to be a valid address for another mailer)
522is scanned for two special cases.
523If prefixed by a vertical bar (\c
524.q \^|\^ )
525the rest of the address is processed as a shell command.
526If the user name contains slash marks (\c
527.q /\^ )
528the name is used as a file name,
529instead of a login name.
530.pp
531Files that have setuid or setgid bits set
532but no execute bits set
533have those bits honored if
534.i sendmail
535is running as root.
536.sh 2 "Aliasing, Forwarding, Inclusion"
537.pp
538.i Sendmail
539reroutes mail three ways.
540Aliasing applies system wide.
541Forwarding allows each user to reroute incoming mail
542destined for that account.
543Inclusion directs
544.i sendmail
545to read a file for a list of addresses,
546and is normally used
547in conjunction with aliasing.
548.sh 3 "Aliasing"
549.pp
550Aliasing maps names to address lists using a system-wide file.
551This file is inverted to speed access.
552Only names that parse as local
553are allowed as aliases;
554this guarantees a unique key.
555.pp
556The inverted form of the file
557must be recreated when the text copy is changed.
558Under certain circumstances,
559.i sendmail
560will do this automatically;
561an option can force rebuilding.
562.sh 3 "Forwarding"
563.pp
564After aliasing,
565users that are local and valid
566are checked for the existence of a
567.q .forward
568file in their home directory.
569If it exists,
570the message is
571.i not
572sent to that user,
573but rather to the list of users in that file.
574The expectation is that this will normally
575be one user only,
576and the use will be for network mail forwarding.
577.pp
578Forwarding also permits a user to specify a private incoming mailer.
579For example,
580forwarding to:
581.(b
582"\^|\|/usr/local/newmail myname"
583.)b
584will use a different incoming mailer.
585.sh 3 "Inclusion"
586.pp
587Inclusion is specified in ARPANET syntax:
588.(b
589:Include: pathname
590.)b
591An address of this form reads the file specified by
592.i pathname
593and sends to all users listed in that file.
594.pp
595The intent is
596.i not
597to support direct use of this feature,
598but rather to use this as a subset of aliasing.
599For example,
600an alias of the form:
601.(b
602project: :include:/usr/project/userlist
603.)b
604is a method of letting a project maintain a mailing list
605without interaction with the system administration,
606even if the alias file is protected.
607.pp
608It is not necessary to rebuild the alias database
609when a :include: list is changed.
610.sh 2 "Message Delivery"
611.pp
612Internally,
613the recipient list is stored as one list per mailer.
614Each mailer list can be scanned trivially
615and mail to each host picked out to implement message batching.
616Each address is marked as it is sent,
617so rescanning the list is safe;
618this makes sending to mailers that can only accept one user easy.
619An argument list is built as the scan proceeds.
620Mail to files is detected during the scan of the send list.
621.pp
622When an argument vector is built,
623.i sendmail
624creates a pipe and subprocess for the mailer.
625The parent calls an
626.q "editing function"
627which makes the per-mailer changes to the header
628and sends the result to the mailer;
629a different editing function is used for sending error messages
630which prepends the error information.
631.pp
632The exit status from the mailer is collected
633after the message is sent,
634and a diagnostic is printed if appropriate.
635If any mail is rejected by the mailer,
636a flag is set to invoke the return-to-sender function
637after all delivery completes.
638.sh 2 "Exit Status"
639.pp
640An exit status is returned that corresponds to the system standard
641used by the other mailers.
642.sh 2 "Interaction With Other Mailers"
643.pp
644Two examples of how network-specific work is passed to other programs
645are the incoming UUCP mailer
646(\c
647.i rmail )
648and the outgoing ARPANET mailer.
649.sh 3 "Incoming UUCP mail"
650.pp
651Mail coming in from the UUCP network
652is not guaranteed to have a normal header line,
653nor will an argument be passed telling who it is from\**.
654.(f
655\**As a result of this,
656it is impossible to verify UUCP sender addresses.
657.)f
658Fortuitously,
659UUCP mail calls the program
660.i rmail
661rather than
662.i mail
663or
664.i sendmail .
665The
666.i rmail
667program has been modified here to do the special-purpose parsing
668necessary to decode UUCP headers
669and turn them into a normal UUCP address;
670this address is then passed to
671.i sendmail .
672.sh 3 "Outgoing ARPANET mail"
673.pp
674The ARPANET imposes many standards that
675.i sendmail
676does not care to enforce.
677For example,
678an arpanet sitename must be on
679.i every
680address,
681not just the
682.q "From:"
683address.
684Certain UNIX sites like to use
685.q %
686as an alternative to
687.q @ ,
688which must be translated.
689The outgoing ARPANET mailer makes these transformations
690before passing the message to the network.
691.sh 1 CONFIGURATION
692.pp
693Configuration is controlled primarily by the file
694.i /usr/lib/sendmail.cf .
695.i Sendmail
696should not need to be recomplied except
697.np
698To change operating systems
699(V6, V7/32V, 4BSD).
700.np
701To remove or insert the DBM library.
702.np
703To change ARPANET reply codes.
704.np
705To add headers requiring special processing.
706.lp
707Adding mailers or changing parsing or routing information
708does not require recompilation.
709.pp
710If the mail is being sent by a local user,
711and the file
712.q .mailcf
713exists in the sender's home directory,
714that file is read as a configuration file
715after the system configuration file.
716The primary use of this is to add header lines.
717.sh 2 "Configuration File Description"
718.pp
719The configuration file is formatted
720as a series of text lines,
721each beginning with a character describing its semantics.
722Blank lines and lines beginning with a sharp sign
723(#)
724are ignored.
725Other lines are:
726.(b
727.ta 3n
728D	define macro
729H	define header
730M	define mailer
731S	use rewriting set
732C	define word class
733R	specify rewriting rule
734.)b
735.pp
736See figure 2 for an example configuration file.
737.(z
738.hl
739.sz -2
740.re
741##########################################
742# sendmail configuration file
743#	@(#)sendmail.cf	3.6	8/17/81
744##########################################
745.sp \n(psu
746### local hosts on various nets
747DABerkeley
748DBIngVAX
749DUucbvax
750.sp \n(psu
751### special macros
752# my name
753D\&n\&MAILER-DAEMON
754# UNIX header format
755D\&l\&From $g  $d
756# delimiter (operator) characters
757D\&o\&.:@!^
758.sp \n(psu
759### format of headers:
760H\&Date: $a
761H\&From: $g$?x ($x)$.
762H\&Full-Name: $x
763H\&Message-Id: <$t.$p.$B@$A>
764H\&Posted-Date: $a
765.sp \n(psu
766### name classifications
767# arpanet hostnames
768C\&A\&ucb berkeley
769# list of local host names
770C\&B\&j IngVax
771# berknet hosts on the arpanet
772C\&C\&i ingres ing70
773# uucp hostnames
774C\&U\&ucbvax ernie
775.sp \n(psu
776.ta \w'M\&local  'u +\w'/usr/net/bin/sendberkmail  'u +\w'rlsAmn  'u +\w'$f@$A  'u
777###  mailers
778# local mail -- must be zero
779M\&local	/bin/mail	rlsAmn	$f	...local\&mail -d $u
780# program mail -- must be one
781M\&prog	/bin/csh	lA	$f	...prog\&mail -fc $u
782# berkeley net mail
783M\&berk	/usr/net/bin/sendberkmail	fxs	$B:$f	...berk\&mail -m $h -h $c -t $u
784# arpanet mail
785M\&arpa	/usr/lib/mailers/arpa	sAu	$f@$A	...arpa\&mail $f $h $u
786# uucp mail
787M\&uucp	/usr/bin/uux	rsDxm	$U!$f	...uucp\&mail - $h!rmail ($u)
788.sp \n(psu
789### rewriting rules
790.ta \w'R\&CSVAX:$-h!$+u  'u +\w'$#berk$@ing70$:$+u@$+h  'u
791R\&$-h.$+u	$+h:$+u	change "." to ":"
792R\&$=C:$+u@$-h	$+u@$+h	delete ing70: on arpanet addresses
793R\&$+u@$=A	ing70:$+u	delete local arpa hosts
794R\&$+u@$-h	$#berk$@ing70$:$+u@$+h	send arpa mail to ing70
795R\&$+h^$+u	$+h!$+u	change "^" to "!"
796R\&$-x!$=U!$+y	csvax:$+y	delete uucp loops through csvax
797R\&$-h!$+u	csvax:$+h!$+u	send uucp mail to csvax
798R\&$-x:$-h:$+u	$+h:$+u	delete multiple berk hosts
799R\&$=B:$+u	$+u	delete local berk hosts
800R\&$-h:$+u	$#berk$@$+h$:$+u	resolve berk mail
801R\&$+u	$#local$:$+u	resolve local mail
802.sp \n(psu
803### rewriting rules for from host
804S\&1
805R\&ing70:$+u@$-h	$+u@$+h	arpanet mail is automatic
806R\&CSVAX:$-h!$+u	$+h!$+u	uucp mail is automatic
807.sz
808.sp
809.ce
810Figure 2.  Sample configuration file.
811.hl
812.)z
813.sh 3 "D \*- define macro"
814.(b
815.b D \c
816.i x\|val
817.)b
818.pp
819This line defines a macro
820with the single character name
821.i x
822and value
823.i val .
824Macros can be interpolated using the escape
825.b $ \c
826.i x ,
827where
828.i x
829is the macro name.
830By convention,
831all upper-case letters are unused by
832.i sendmail
833and may be used freely by the user;
834all other names are reserved for use by sendmail.
835Certain macros
836.i must
837be defined,
838and are used internally.
839These are:
840.(b
841.ta 4n
842$l	UNIX-style \*(lqFrom\*(rq line.
843$n	My address in error messages.
844$o	\*(lqOperators\*(rq in addresses.
845.)b
846The
847.b $l
848macro is expanded when
849.i sendmail
850wants to insert a UNIX-style
851.q From
852line on messages.
853This typically expands to something like:
854.(b
855From sally  Wed Aug 12 09:15:13 1981
856.)b
857The
858.b $n
859macro is used as the name of this process
860when error messages are being mailed back.
861Typically,
862it is wise to include an alias
863so that mail to this address will be sent to root.
864The
865.b $o
866macro defines the characters
867that will separate words when addresses are being broken up.
868Each of these becomes a word by itself when scanned.
869Blanks and tabs are built-in separators
870but are ignored,
871i.e., are not turned into words.
872For example, the input:
873.(b
874Ing70:  ZRM  @  MIT-MC  SRI-KL
875.)b
876Is broken up into the six words:
877.(b
878Ing70, :, ZRM, @, MIT-MC, SRI-KL
879.)b
880assuming that colon and at-sign are operators
881(but hyphen is not).
882.pp
883A number of macros are defined by
884.i sendmail
885for use as primitives.
886These are:
887.(l
888.ta 5n
889$a	The \*(lqDate:\*(rq line date in ARPANET format.
890$b	The current date in ARPANET format.
891$c	The hop count.
892$d	The date in UNIX (ctime) format.
893$f	The sender's (from) address.
894$g	The sender's address translated by the mailer.
895$h	The host of the recipient.
896$p	The process id of sendmail in decimal.
897$t	The time in seconds in decimal.
898$u	The user part of the recipient.
899$v	The version number of sendmail.
900$x	The full name of the sender.
901$y	The id of the sender's terminal.
902$z	The home directory of the recipient.
903.)l
904.pp
905There are three types of dates that can be used.
906The
907.b $a
908and
909.b $b
910macros are in ARPANET format;
911.b $a
912is a copy of the time extracted from the
913.q Date:
914field of the incoming message
915(if there was one),
916and
917.b $b
918is the current date and time \*- used for postmarks.
919If no
920.q Date:
921is found in the message,
922they are the same.
923The
924.b $d
925macro has the date in UNIX
926.i ctime
927format;
928this is extracted from the message if possible
929and is otherwise the current date.
930.pp
931The
932.b $f
933macro is the id of the sender
934as originally determined;
935when mailing to a specific person,
936the
937.b $g
938macro is the address of the sender
939with respect to the receiver.
940For example,
941if I send to
942.q csvax:samwise
943the
944.b $f
945and
946.b $g
947macros are:
948.(b
949.ta 4n
950$f	eric
951$g	IngVAX:eric
952.)b
953This only applies to the first step in the link.
954For example,
955sending to Ing70:drb@bbn-unix,
956we have
957.b $f
958and
959.b $g
960as above for the transfer to Ing70, but:
961.(b
962$f	IngVAX:eric
963$g	IngVAX:eric@Berkeley
964.)b
965for transfer to the ARPANET.
966.pp
967The
968.b $x
969macro is set to the full name of the sender.
970This can be determined in several ways.
971It can be passed as a flag to
972.i sendmail .
973The
974.q Full-Name:
975line in the header is the second option,
976and the comment portion of the
977.q From:
978line is the third.
979If all of these fail,
980and if the message is being originated locally,
981the full name is looked up in the
982.i passwd
983file.
984.pp
985When sending, the
986.b $u ,
987.b $h ,
988and
989.b $z
990macros get set to the user, host, and home directory
991(respectively)
992of the receiver.
993The host is only set if the user is not local,
994and the home directory is only set if the user is local.
995.pp
996The
997.b $p
998and
999.b $t
1000macros are used to create unique strings.
1001The
1002.b $y
1003macro is set to the id of the terminal of the sender
1004(if known);
1005some systems like to put this in the
1006.q From
1007line.
1008The
1009.b $v
1010macro is set to the version number of
1011.i sendmail ,
1012and can be used in postmarks
1013to help debugging.
1014.pp
1015A primitive conditional is available during macro expansion.
1016The construct:
1017.(b
1018$?x text1 $: text2 $.
1019.)b
1020tests if macro
1021.b $ \c
1022.i x
1023is defined.
1024If it is,
1025text1 is interpolated;
1026otherwise,
1027text2 is interpolated.
1028.sh 3 "H \*- define header"
1029.(b
1030.b H \c
1031.i "Field-Name" \c
1032.b ":" " \c
1033.i "field value"
1034.)b
1035.pp
1036The
1037.b H
1038line looks like a regular header line,
1039except that the field value is macro expanded
1040before use.
1041All headers mentioned in this way
1042are automatically inserted
1043into every message
1044except for headers mentioned in the compile-time
1045configuration file
1046.i conf.c .
1047These headers are
1048Date,
1049From,
1050Full-Name,
1051Message-Id,
1052and
1053Received-Date.
1054To get these fields the appropriate flag
1055must be specified
1056for the receiving mailer.
1057.pp
1058Since the file
1059.q ".mailcf"
1060in the sender's home directory is read and processed,
1061it is possible to add customized header lines.
1062For example,
1063the .mailcf consisting of:
1064.(b
1065H\&Phone: (415) 888-7770
1066.)b
1067will add that line to every outgoing message.
1068.sh 3 "M \*- define mailer"
1069.(b F
1070.b M \c
1071.i mailer-name
1072.i pathname
1073.i flags
1074.i from-macro
1075.i "argument list"
1076.)b
1077.pp
1078This line is structured into fields
1079separated by white space (spaces or tabs).
1080The fields are:
1081.np
1082The internal name of the mailer,
1083referred to in the rewriting rules.
1084.np
1085The pathname of the program to execute for this mailer.
1086.np
1087The flags for this mailer,
1088described below.
1089.np
1090The macro string to become the
1091.b $g
1092macro (translated sender)
1093for this mailer.
1094.np
1095The argument vector passed to the mailer
1096(macro expanded).
1097.pp
1098The flags are a series of characters:
1099.ls 1
1100.ip f
1101The mailer wants a
1102.b \-f
1103.i from
1104flag,
1105but only if this is a network forward operation
1106(i.e.,
1107the mailer will give an error
1108if the executing user does not have special permissions).
1109.ip r
1110Same as
1111.b f ,
1112but sends a
1113.b \-r
1114flag.
1115.ip q
1116Don't print errors \*- the mailer will do it for us.
1117.ip S
1118Don't reset your userid before calling the mailer.
1119This would be used in a secure environment where
1120.i sendmail
1121ran as a special user.
1122This could be used to prevent
1123(or at least complicate)
1124forged addresses.
1125This option is suppressed in
1126.q unsafe
1127configuration files
1128(i.e., user-supplied, either on a
1129command line
1130option, or in the
1131.i \&.mailcf
1132file in the home directory).
1133.ip n
1134This mailer does not want a UNIX-style
1135.q From
1136line on the message.
1137.ip l
1138This mailer is local,
1139so no host will be specified.
1140Also,
1141the mailer wants special local processing
1142(such as a
1143.q Received-Date:
1144field).
1145.ip s
1146Strip quote characters off of addresses
1147before calling the mailer.
1148.ip m
1149This mailer can send to multiple users
1150(on the same host)
1151in one call.
1152.ip F
1153This mailer wants a
1154.q From:
1155header line.
1156.ip D
1157This mailer wants a
1158.q Date:
1159header line.
1160.ip M
1161This mailer wants a
1162.q Message-Id:
1163header line.
1164.ip x
1165This mailer wants a
1166.q Full-Name:
1167header line.
1168.ip u
1169Upper case should be preserved in user names.
1170.ip h
1171Upper case should be preserved in host names.
1172.ip A
1173This mailer wants an ARPANET standard header
1174(equivalent to the
1175.b F
1176and
1177.b D
1178flags).
1179.ls
1180.sh 3 "S \*- use rewriting set"
1181.(b
1182.b S \c
1183.i N
1184.)b
1185.pp
1186There are two sets of rewriting rules.
1187Set zero is used to rewrite recipient addresses.
1188Set one is used to rewrite sender addresses.
1189Set one can be used to eliminate implicit links.
1190For example,
1191if there exists a site on on the BerkNet called
1192.q Ing70
1193which is an ARPANET gateway,
1194and we are on a site called
1195.q IngVAX ,
1196ARPANET mail coming into
1197.q Ing70
1198for someone on
1199.q IngVAX
1200will read:
1201.(b
1202From: Ing70:auser@ahost
1203.)b
1204Rewriting set one can rewrite this as:
1205.(b
1206From: auser@ahost
1207.)b
1208since
1209.q Ing70
1210will be implied.
1211.pp
1212When you change to a new set,
1213the previous content of that set is cleared.
1214.sh 3 "R \*- rewriting rule"
1215.(b F
1216.b R \c
1217.i pattern
1218.i replacement
1219.i comments
1220.)b
1221.pp
1222The rewriting rules drive the address parser.
1223The rewriting process is essentially textual.
1224First,
1225the address to be rewritten is broken up into words.
1226Words are defined as strings of non-special characters
1227separated by white space or single special characters
1228as defined by the
1229.b $o
1230macro.
1231Then,
1232the words are rewritten using simple pattern matching.
1233Words in the pattern match themselves
1234unless they begin with dollar sign.
1235The dollar escapes have the following meanings\**:
1236.(f
1237\**These dollar escapes have nothing to do with macro expansion.
1238.)f
1239.(b
1240.ta 6n
1241$-x	Match a single word (and call it x).
1242$+x	Match one or more words (and call them x).
1243$=c	Match any word in class c (see below).
1244.)b
1245The case of letters is ignored in pattern matching
1246(including class comparisons).
1247.pp
1248When a pattern (also called a left hand side or LHS)
1249matches,
1250the input is rewritten as defined by the right hand side (RHS).
1251Acceptable escapes in the RHS are:
1252.(b
1253.ta \w'$#mailer  'u
1254$+x	Replace from corresponding match in LHS.
1255$#mailer	Canonical mailer name.
1256$@host	Canonical host name.
1257$:user	Canonical user name.
1258.)b
1259The replacement from the LHS to the RHS does not use macros,
1260and there are no name conflicts.
1261Each pattern reexecutes until it fails.
1262As soon as the input resolves to a canonical name
1263(i.e.,
1264.q "$#mailer$@host$:user" ),
1265rewriting ends;
1266otherwise,
1267the next pattern is tried.
1268The
1269.q "$@host"
1270part is not needed
1271if the mailer does not require a host.
1272The special mailer
1273.q error
1274causes the user part to be printed as an error.
1275.sh 3 "C \*- define word class"
1276.(b F
1277.b C \c
1278.i c\|word\&1
1279.i word\&2 ...
1280.)b
1281.pp
1282There are twenty six word classes,
1283represented as
1284.q A
1285through
1286.q Z .
1287For example:
1288.(b
1289CVcsvax ingvax esvax
1290.)b
1291defines the words
1292.q csvax ,
1293.q ingvax ,
1294and
1295.q esvax
1296to all be in class
1297.q V ,
1298so that
1299.q $=V
1300on the LHS of a rewriting rule
1301will match any of these words.
1302.sh 2 "A Detailed Example"
1303.pp
1304We will now follow the configuration file
1305in figure 2
1306through in detail.
1307.sh 3 "Macro definitions"
1308.(b
1309DABerkeley
1310DBIngVAX
1311DUucbvax
1312DnMAILER-DAEMON
1313DlFrom $g  $d
1314Do.:@!^
1315.)b
1316The first three macros are for convenience only,
1317and are used to define the local host names
1318on the ARPANET, BerkNet, and the UUCP net
1319respectively.
1320.pp
1321Macro
1322.b n
1323defines the name of
1324.i sendmail
1325when error messages are sent.
1326Macro
1327.b l
1328defines what the first line
1329of a message in UNIX format looks like,
1330in this case the version 7 standard of:
1331.(b
1332From sender-name  time-of-submission
1333.)b
1334The
1335.b o
1336macro
1337tells what characters will be distinct from names
1338when scanning addresses.
1339In this case,
1340dot and colon will be used
1341to distinguish BerkNet addresses,
1342at sign for ARPANET addresses,
1343and exclamation point and caret for UUCP addresses.
1344.sh 3 "Header definitions"
1345.(b
1346H\&Date: $a
1347H\&From: $g$?x ($x)$.
1348H\&Full-Name: $x
1349H\&Message-Id: <$t.$p.$B@$A>
1350H\&Posted-Date: $a
1351.)b
1352These define the headers
1353that may be added to a message.
1354The
1355.q Date:
1356is just the ARPANET idea of the date.
1357The
1358.q From:
1359line is the translated version of the sender,
1360followed by the sender's full name if known.
1361The
1362.q Full-Name:
1363field is used to transmit the sender's full name
1364when a
1365.q From:
1366line is not being sent;
1367these will normally be mutually exclusive.
1368The
1369.q Message-Id:
1370field has the time and process id's concatenated
1371with the BerkNet and ARPANET addresses
1372to make a unique string.
1373Finally, the
1374.q Posted-Date:
1375is the date in ARPANET format;
1376it differs from
1377.q Date:
1378in that it is always output as soon as the message enters
1379.i sendmail 's
1380domain,
1381and hence indicates the time that the message first enters
1382the mail delivery system
1383[Postel79b, NBS80].
1384.sh 3 "Name classifications"
1385.(b
1386C\&A\&ucb berkeley
1387C\&B\&j IngVax
1388C\&C\&i ingres ing70
1389C\&U\&ucbvax ernie
1390.)b
1391These commands put the words
1392.q ucb
1393and
1394.q berkeley
1395into class
1396.q A ,
1397the valid names of this site on the ARPANET.
1398Words
1399.q j
1400and
1401.q ingvax
1402are in class
1403.q B ,
1404the local names on BerkNet.
1405Class
1406.q C ,
1407the names of the site which has the ARPANET link,
1408has the words
1409.q i ,
1410.q ingres ,
1411and
1412.q ing70 .
1413Finally,
1414.q ucbvax
1415and
1416.q ernie
1417are the UUCP names of our UUCP gateway,
1418and are in class
1419.q U .
1420.pp
1421The classes will be used in the patterns of the rewriting rules
1422as described below.
1423.sh 3 "Mailer definitions"
1424.(b
1425.sz -2
1426.ta \w'M\&local  'u +\w'/usr/net/bin/sendberkmail  'u +\w'rlsAmn  'u +\w'$f@$A  'u
1427M\&local	/bin/mail	rlsAmn	$f	...localmail -d $u
1428M\&prog	/bin/csh	lA	$f	...progmail -fc $u
1429M\&berk	/usr/net/bin/sendberkmail	fxs	$B:$f	...berkmail -m $h -h $c -t $u
1430M\&arpa	/usr/lib/mailers/arpa	sAu	$f@$A	...arpamail $f $h $u
1431M\&uucp	/usr/bin/uux	rsDxm	$U!$f	...uucpmail - $h!rmail ($u)
1432.sz
1433.)b
1434Five mailers are known in the configuration file.
1435The first two
1436.i must
1437be for local and program mail,
1438and must come as the first and second mailers respectively.
1439.pp
1440Local mail is sent using
1441/bin/mail.
1442It takes a
1443.b \-r
1444flag,
1445is local,
1446quote characters are stripped before sending,
1447takes ARPANET standard headers,
1448can deliver to multiple recipients at once,
1449and does not want a UNIX-style
1450.q From
1451line since it will add one itself.
1452The translated from address is the same as the raw from address,
1453since no network hops are made.
1454The argument vector has a program name,
1455a
1456.b \-d
1457flag (\c
1458.q "really deliver" ,
1459which must be added to /bin/mail),
1460and the list of recipients \*- one recipient per argument.
1461.pp
1462Mail piped through programs
1463is interpreted by /bin/csh.
1464Unlike local mail,
1465it does not take a
1466.b \-r
1467flag,
1468quotes should be left,
1469it can only deal with one user,
1470and it does want a UNIX-style
1471.q From
1472line,
1473but is still local and still wants an ARPANET style header.
1474.pp
1475BerkNet mail is processed by
1476/usr/net/bin/sendberkmail.
1477It takes a
1478.b \-f
1479flag,
1480wants a
1481.q Full-Name:
1482header line,
1483and wants quotes stripped.
1484The
1485.q Full-Name:
1486is used here because if it were given as a comment
1487in a
1488.q From:
1489line the machine address of the sender
1490would not be modified by later instantiations of
1491.i delivermail \**.
1492.(f
1493\**\c
1494.i Delivermail
1495did no header editing,
1496so
1497.q From:
1498lines were always passed untouched.
1499When the gateways are converted to
1500.i sendmail
1501this can be changed.
1502.)f
1503The from address as seen by the receiver is
1504.q IngVAX:sender ,
1505and it takes a flag-oriented
1506rather than a positional
1507command list.
1508.pp
1509The ARPANET wants quotes stripped,
1510ARPANET standard headers,
1511and wants the user name left with case intact.
1512It takes a positional command list.
1513.pp
1514UUCP mail calls
1515.i uux
1516with a
1517.b \-r
1518flag,
1519quotes stripped,
1520a
1521.q Date:
1522line,
1523a
1524.q Full-Name:
1525line,
1526and with multiple users listed.
1527.sh 3 "Rewriting rules for recipient addresses"
1528.(b
1529.sz -2
1530.ta \w'[88]  'u +\w'R\&CSVAX:$-h!$+u  'u +\w'$#berk$@ing70$:$+u@$+h  'u
1531[1]	R\&$-h.$+u	$+h:$+u	change "." to ":"
1532[2]	R\&$=C:$+u@$-h	$+u@$+h	delete ing70: on arpanet addresses
1533[3]	R\&$+u@$=A	ing70:$+u	delete local arpa hosts
1534[4]	R\&$+u@$-h	$#berk$@ing70$:$+u@$+h	send arpa mail to ing70
1535[5]	R\&$+h^$+u	$+h!$+u	change "^" to "!"
1536[6]	R\&$-x!$=U!$+y	csvax:$+y	delete uucp loops through csvax
1537[7]	R\&$-h!$+u	csvax:$+h!$+u	send uucp mail to csvax
1538[8]	R\&$-x:$-h:$+u	$+h:$+u	delete multiple berk hosts
1539[9]	R\&$=B:$+u	$+u	delete local berk hosts
1540[10]	R\&$-h:$+u	$#berk$@$+h$:$+u	resolve berk mail
1541[11]	R\&$+u	$#local$:$+u	resolve local mail
1542.sz
1543.)b
1544The first rule translates dots to colons.
1545Redundant explicit routing to the ARPANET is deleted
1546in the second rule.
1547Hops out over the ARPANET
1548back to us are deleted in the third rule \*-
1549note that the BerkNet host that we would have come in on
1550is inserted.
1551Real ARPANET mail is resolved immediately with no further ado \*-
1552it is sent out over the BerkNet to the ing70,
1553and further rewriting stops immediately.
1554.pp
1555Carets are changed to exclamation points
1556for UUCP addresses in the fifth rule.
1557The sixth rule deletes loops out into UUCP land
1558and back to us \*- noting that we will be left on CSVAX.
1559Multiple BerkNet hosts are deleted in rule seven \*-
1560this can occur internally quite easily
1561as a side effect of a rewriting rule.
1562Rule eight deletes local BerkNet hosts.
1563The last two rules resolve BerkNet and local mail.
1564.pp
1565Consider the following examples.
1566The numbers to the left are the rule that is being applied
1567to make the transformation.
1568.(b
1569.re
1570	esvax.asa
1571[1]	esvax:asa
1572[10]	$#berk$@esvax$:asa
1573.)b
1574.(b
1575	research^vax135^dmr
1576[5]	research!vax135^dmr
1577[5]	research!vax135!dmr
1578[7]	$#berk$@csvax$:research!vax135!dmr
1579.)b
1580.(b
1581	research!ucbvax!j:eric
1582[6]	csvax:j:eric
1583[8]	j:eric
1584[9]	eric
1585[11]	$#local$:eric
1586.)b
1587.(b
1588	ing70:wnj@Berkeley
1589[2]	wnj@Berkeley
1590[3]	ing70:wnj
1591[10]	$#berk$@ing70$:wnj
1592.)b
1593.sh 3 "Rewriting rules for sender addresses"
1594.(b
1595.sz -2
1596.ta \w'R\&CSVAX:$-h!$+u  'u +\w'$+u@$+h  'u
1597S\&1
1598R\&ing70:$+u@$-h	$+u@$+h	arpanet mail is automatic
1599R\&CSVAX:$-h!$+u	$+h!$+u	uucp mail is automatic
1600.sz
1601.)b
1602The
1603.b S
1604line starts putting the rules into set one.
1605These rules strip off the
1606.q ing70:
1607from incoming ARPANET mail
1608and the
1609.q CSVAX:
1610off of incoming UUCP mail.
1611.pp
1612The name classes could be used here,
1613but using literal strings is safe
1614because they will always be program-generated.
1615.sh 1 "COMPARISON WITH OTHER MAILERS"
1616.sh 2 "Delivermail"
1617.pp
1618.i Sendmail
1619is an outgrowth of
1620.i delivermail .
1621The primary differences are:
1622.np
1623Configuration information is not compiled in.
1624This simplifies many of the problems
1625of moving to other machines.
1626It also allows easy debugging of new mailers.
1627.np
1628Address parsing is more flexible.
1629For example,
1630.i delivermail
1631only supported one gateway to any network,
1632whereas
1633.i sendmail
1634can be sensitive to host names
1635and reroute to different gateways.
1636.np
1637Forwarding and
1638:include:
1639features eliminate the requirement that the system alias file
1640be writable by any user
1641(or that an update program be written,
1642or that the system administration make all changes).
1643.np
1644.i Sendmail
1645supports message batching across networks
1646when a message is being sent to multiple recipients.
1647.sh 2 "MMDF"
1648.pp
1649MMDF
1650[Crocker79]
1651spans a much wider problem set than
1652.i sendmail .
1653For example,
1654MMDF includes a
1655.q "phone network"
1656mailer, whereas
1657.i sendmail
1658calls on preexisting mailers in most cases.
1659.i Sendmail
1660is approximately equivalent to the
1661SUBMIT and DELIVER phases of MMDF.
1662Because of this difference in design goals,
1663some of the important features of MMDF
1664(queueing, retransmission, and two-phase timeout)
1665are unimplemented by
1666.i sendmail .
1667.pp
1668MMDF and
1669.i sendmail
1670both support aliasing,
1671customized mailers,
1672message batching,
1673and automatic forwarding to gateways.
1674.sh 2 "Message Processing Module"
1675.pp
1676The Message Processing Module (MPM)
1677discussed by Postel [Postel79b]
1678matches
1679.i sendmail
1680closely in terms of its basic architecture.
1681However,
1682like MMDF,
1683the MPM includes the network interface software
1684as part of its domain.
1685.pp
1686MPM also postulates a duplex channel to the receiver,
1687as does MMDF.
1688This allows simpler handling of errors
1689by the mailer
1690than possible in
1691.i sendmail ;
1692when a message queued by
1693.i sendmail
1694is sent,
1695any errors must be returned to the sender
1696by the mailer itself.
1697Both MPM and MMDF mailers
1698can return an immediate error response,
1699and a single error processor can create an appropriate response.
1700.pp
1701MPM prefers passing the message as a structured message,
1702with type-length-value tuples.
1703This implies a much higher degree of cooperation
1704between mailers than required by
1705.i sendmail .
1706MPM also assumes a universally agreed upon internet name space
1707(with each address a net-host-user tuple),
1708which
1709.i sendmail
1710does not.
1711.sh 1 "EVALUATIONS AND FUTURE PLANS"
1712.pp
1713.i Sendmail
1714is designed to work in a nonhomogeneous environment.
1715Every attempt is made to avoid imposing any constraints
1716on the underlying mailers.
1717This goal has driven much of the design.
1718One of the major problems
1719has been the lack of a uniform address space,
1720as postulated in [Postel79a]
1721and [Postel79b].
1722.pp
1723A nonuniform address space implies that path will be specified
1724in all addresses,
1725either explicitly (as part of the address)
1726or implicitly
1727(as with implied forwarding to gateways).
1728This has the unpleasant effect of making replying to messages
1729exceedingly difficult,
1730since there is no one
1731.q address
1732for any person,
1733but only a way to get there from wherever you are.
1734.pp
1735Interfacing to mail programs
1736that were not initially intended to be applied
1737in an internet environment
1738has been amazingly successful,
1739and has reduced the job to a manageable task.
1740.pp
1741However,
1742many of these mailers implement their own queueing and retransmission.
1743In networks that support store-and-forward file transfer,
1744such as BerkNet and UUCP,
1745this feature must be supplied already.
1746However,
1747networks that transfer in real time,
1748such as the ARPANET or an Ether-based network
1749[Metcalfe76],
1750generally do not provide these features.
1751Also,
1752networks which provide these generally do not understand
1753timeouts or returning the text of the message on error,
1754both highly desirable features\**.
1755.(f
1756\**We have implemented an ARPANET mailer which
1757returns the message on error and does one-stage timeout
1758(returning the message after three days).
1759.)f
1760Such queueing, retransmission, and two-phase timeout
1761may be integrated into
1762.i sendmail
1763if it seems desirable.
1764.pp
1765.i Sendmail
1766has knowledge of a few difficult environments
1767built in.
1768It generates ARPANET FTP compatible error messages
1769(prepended with three-digit numbers
1770[Neigus73, Postel74])
1771as necessary,
1772optionally generates UNIX-style
1773.q From
1774lines on the front of messages for some mailers,
1775and knows how to parse the same lines on input.
1776This can be inconvenient to sites which have abandoned UNIX mail,
1777although
1778.i sendmail
1779still adds and understands ARPANET-style
1780.q From:
1781lines.
1782Also,
1783error handling has an option customized for BerkNet.
1784.pp
1785One surprisingly major annoyance in most internet mailers
1786(such as MMDF)
1787is that the location and format of local mail is built in\**.
1788.(f
1789\**For example,
1790MMDF puts local mail in the file
1791.q .mail
1792\*- useful if you are running version 6.
1793.)f
1794.i Sendmail
1795eliminates all knowledge of location
1796and can function successfully with different formats.
1797.pp
1798The ability to automatically generate a response to incoming mail
1799(by forwarding mail to a program)
1800seems useful
1801(\c
1802.q "I am on vacation until late August...." )
1803but can create problems
1804such as forwarding loops
1805(two people on vacation whose programs send notes back and forth,
1806for instance)
1807if these programs are not well written.
1808A program should be written to do standard tasks correctly,
1809but this does not solve the general case.
1810It might be desirable to implement some form of load limiting.
1811I am unaware of any mail system that addresses this problem,
1812nor am I aware of any reasonable solution at this time.
1813.pp
1814.i Sendmail
1815should be modified to run as a daemon,
1816reading an MPX file
1817(or other IPC scheme)
1818to receive mail and process it.
1819This would reduce the cost of sending mail to writing the message
1820into a known file.
1821.i Sendmail
1822would be modified to have a very different argument structure.
1823It already has an option to read the recipients
1824from the message header.
1825A more palatable technique for giving error messages
1826would also have to be devised.
1827.pp
1828The configuration file is currently practically inscrutable;
1829considerable convenience could be realized
1830with a higher-level format.
1831For example, a description might read:
1832.(b
1833.re
1834(MACRO name value)
1835(HEADER name value
1836	(OPTION option) ...
1837	(NEEDS option) ... )
1838(MAILER name path xlatstring
1839	(OPTION option) ...
1840	(ARGV arg ... ))
1841(CLASS name word ...)
1842(REWRITE setname
1843	(RULE lhs rhs) ... )
1844.)b
1845.pp
1846It seems clear that common protocols will be changing soon
1847to accommodate changing requirements and environments.
1848These changes will include modifications to the message header
1849[NBS80]
1850or to the body of the message itself
1851(such as for multimedia messages
1852[Postel80]).
1853Other changes will include changes to communication protocols
1854which may effect
1855.i sendmail ;
1856for example, the changes implied by the new Mail Transfer Protocol
1857[Sluizer81].
1858These changes should be relatively trivial to integrate
1859into the existing system.
1860.pp
1861Many other nice features could be implemented.
1862For example,
1863if we were sure that the alias file were writable by the effective user
1864(i.e., if
1865.i sendmail
1866were to run setuid)
1867then the inverted form could be rebuilt automatically when the
1868text copy was changed.
1869However, this appears to be little more than frosting.
1870.pp
1871Some proposals call for a single address syntax,
1872such that the host name uniquely determines the network.
1873There are a number of evident problems with this.
1874In a large internet,
1875the database update problem becomes considerable,
1876especially under multiple managements;
1877this can be solved by a daemon that updates the tables
1878dynamically,
1879but it is not clear what the problems are here.
1880More to the point,
1881this requires a unique namespace among all networks.
1882In our current configuration
1883we have been unable to even find out the names of all the hosts
1884on the UUCP network;
1885to hope that on an internet with fifty or more networks
1886would have no name conflicts is beyond the scope of
1887.i sendmail .
1888Despite the difficulties, however,
1889this is probably a better long-term solution to the problem
1890of internet addressing.
1891The ambiguities implied by addresses combining
1892left-associative and right-associative addresses
1893are impossible to solve without parentheses;
1894acceptable for mathematical equations,
1895but absurd for network addresses.
1896.pp
1897A related problem occurs with the user namespace.
1898In tightly coupled environments,
1899it would be nice to have automatic forwarding between machines
1900on the basis of the user name alone,
1901without cumbersome aliases.
1902This would require an automatically updated database
1903and some method of resolving conflicts.
1904Ideally this would be effective even with multiple managements.
1905A student at Berkeley,
1906Alan Biocca,
1907is working on a facility which may provide the necessary functionality.
1908.pp
1909In the long run,
1910a system that understands canonical internet addresses
1911(net, host, user)
1912implemented in a world that understands these addresses
1913would be an incredible win.
1914.i Sendmail
1915seems to be a useful tool to pull together
1916the haphazard environment that exists today,
1917until the better tools permeate the internetwork world.
1918.sh 0 "ACKNOWLEDGEMENTS"
1919.pp
1920Thanks are due to Kurt Shoens for his continual cheerful
1921assistance and good advice,
1922Bill Joy for pointing me in the correct direction
1923(over and over),
1924and Mark Horton for more advice,
1925prodding,
1926and many of the good ideas.
1927Kurt and Eric Schmidt are to be credited
1928for using
1929.i delivermail
1930as a server for their programs
1931(\c
1932.i Mail
1933and BerkNet respectively)
1934before any sane person should have,
1935and making the necessary modifications
1936promptly and happily.
1937Eric gave me considerable advice about the perils
1938of network software which saved me an unknown
1939amount of work and grief.
1940Mark did the original implementation of the DBM version
1941of aliasing, installed the VFORK code,
1942wrote the current version of
1943.i rmail ,
1944and was the person who really convinced me
1945to put the work into
1946.i delivermail
1947to turn it into
1948.i sendmail .
1949Kurt deserves accolades for using
1950.i sendmail
1951when I was myself afraid to take the risk;
1952how a person can continue to be so enthusiastic
1953in the face of so much bitter reality is beyond me.
1954.pp
1955Kurt and Kirk McKusick
1956read early copies of this paper,
1957giving considerable useful advice.
1958.pp
1959Special thanks are reserved for Mike Stonebraker,
1960who knowingly allowed me to put so much work into this
1961when there were so many other things I really should
1962have been working on.
1963.+c
1964.ce
1965REFERENCES
1966.nr ii 1.5i
1967.ip [Crocker77a]
1968Crocker, D. H.,
1969Vittal, J. J.,
1970Pogran, K. T.,
1971and
1972Henderson, D. A. Jr.,
1973.ul
1974Standard for the Format of ARPA Network Text Messages.
1975RFC 733,
1976NIC 41952.
1977In [Feinler78].
1978November 1977.
1979.ip [Crocker77b]
1980Crocker, D. H.,
1981.ul
1982Framework and Functions of the MS Personal Message System.
1983R-2134-ARPA,
1984Rand Corporation,
1985Santa Monica, California.
19861977.
1987.ip [Crocker79]
1988Crocker, D. H.,
1989Szurkowski, E. S.,
1990and
1991Farber, D. J.,
1992.ul
1993An Internetwork Memo Distribution Facility \*- MMDF.
19946th Data Communication Symposium,
1995Asilomar.
1996November 1979.
1997.ip [Metcalfe76]
1998Metcalfe, R.,
1999and
2000Boggs, D.,
2001.q "Ethernet: Distributed Packet Switching for Local Computer Networks" ,
2002.ul
2003Communications of the ACM 19,
20047.
2005July 1976.
2006.ip [Feinler78]
2007Feinler, E.,
2008and
2009Postel, J.
2010(eds.),
2011.ul
2012ARPANET Protocol Handbook.
2013NIC 7104,
2014Network Information Center,
2015SRI International,
2016Menlo Park, California.
20171978.
2018.ip [Borden79]
2019Borden, S.,
2020Gaines, R. S.,
2021and
2022Shapiro, N. Z.,
2023.ul
2024The MH Message Handling System: Users' Manual.
2025R-2367-PAF.
2026Rand Corporation.
2027October 1979.
2028.ip [NBS80]
2029National Bureau of Standards,
2030.ul
2031Specification of a Draft Message Format Standard.
2032Report No. ICST/CBOS 80-2.
2033October 1980.
2034.ip [Neigus73]
2035Neigus, N.,
2036.ul
2037File Transfer Protocol for the ARPA Network.
2038RFC 542, NIC 17759.
2039In [Feinler78].
2040August, 1973.
2041.ip [Nowitz78a]
2042Nowitz, D. A.,
2043and
2044Lesk, M. E.,
2045.ul
2046A Dial-Up Network of UNIX Systems.
2047Bell Laboratories.
2048In
2049UNIX Programmer's Manual, Seventh Edition,
2050Volume 2.
2051August, 1978.
2052.ip [Nowitz78b]
2053Nowitz, D. A.,
2054.ul
2055Uucp Implementation Description.
2056Bell Laboratories.
2057In
2058UNIX Programmer's Manual, Seventh Edition,
2059Volume 2.
2060October, 1978.
2061.ip [Postel74]
2062Postel, J.,
2063and
2064Neigus, N.,
2065Revised FTP Reply Codes.
2066RFC 640, NIC 30843.
2067In [Feinler78].
2068June, 1974.
2069.ip [Postel77]
2070Postel, J.,
2071.ul
2072Mail Protocol.
2073NIC 29588.
2074In [Feinler78].
2075November 1977.
2076.ip [Postel79a]
2077Postel, J.,
2078.ul
2079Internet Message Protocol.
2080RFC 753,
2081IEN 85.
2082Network Information Center,
2083SRI International,
2084Menlo Park, California.
2085March 1979.
2086.ip [Postel79b]
2087Postel, J. B.,
2088.ul
2089An Internetwork Message Structure.
2090In
2091.ul
2092Proceedings of the Sixth Data Communications Symposium,
2093IEEE.
2094New York.
2095November 1979.
2096.ip [Postel80]
2097Postel, J. B.,
2098.ul
2099A Structured Format for Transmission of Multi-Media Documents.
2100RFC 767.
2101Network Information Center,
2102SRI International,
2103Menlo Park, California.
2104August 1980.
2105.ip [Schmidt79]
2106Schmidt, E.,
2107.ul
2108An Introduction to the Berkeley Network.
2109University of California, Berkeley California.
21101979.
2111.ip [Shoens79]
2112Shoens, K.,
2113.ul
2114Mail Reference Manual.
2115University of California, Berkeley.
2116In UNIX Programmer's Manual,
2117Seventh Edition,
2118Volume 2C.
2119December 1979.
2120.ip [Sluizer81]
2121Sluizer, S.,
2122and
2123Postel, J. B.,
2124.ul
2125Mail Transfer Protocol.
2126RFC 780.
2127Network Information Center,
2128SRI International,
2129Menlo Park, California.
2130May 1981.
2131.ip [UNIX80]
2132.ul
2133The UNIX Programmer's Manual, Seventh Edition,
2134Virtual VAX-11 Version,
2135Volume 1.
2136Bell Laboratories,
2137modified by the University of California,
2138Berkeley California.
2139November 1980.
2140.++ A
2141.+c "SENDMAIL USAGE"
2142.pp
2143Arguments must be presented with flags before addresses.
2144The flags are:
2145.nr ii 1i
2146.ip "\-f addr"
2147The sender's machine address is
2148.i addr .
2149This flag is ignored unless the real user
2150is root,
2151network,
2152or uucp,
2153or if
2154.i addr
2155contains an exclamation point
2156(because of certain restrictions in UUCP).
2157.ip "\-r addr"
2158An obsolete form of
2159.b \-f .
2160.ip "\-h cnt"
2161Sets the
2162.q "hop count"
2163to
2164.i cnt .
2165This represents the number of times this message has been processed
2166by
2167.i sendmail
2168(to the extent that it is supported by the underlying networks).
2169.i Cnt
2170is incremented during processing,
2171and if it reaches
2172MAXHOP
2173(currently 30)
2174.i sendmail
2175throws away the message with an error.
2176.ip "\-F\&name"
2177Sets the full name of this user to
2178.i name .
2179.ip \-e\&p
2180Print error messages (default).
2181.ip \-e\&q
2182Throw away error messages.
2183The only response is the exit status.
2184.ip \-e\&m
2185Mail back errors.
2186.ip \-e\&w
2187.q Write
2188back errors \*- or mail them if the user is not logged in.
2189.ip \-e\&e
2190Do special error processing for BerkNet.
2191This involves mailing back the errors
2192but always returning a zero exit status.
2193.ip \-n
2194Don't do aliasing or forwarding.
2195.ip \-m
2196Include me in alias expansions.
2197Normally
2198.i sendmail
2199suppresses the sender
2200if in a group being sent to.
2201.ip \-i
2202Don't take a dot to end a message.
2203.ip \-t
2204Read the header for
2205.q To: ,
2206.q Cc: ,
2207and
2208.q Bcc:
2209lines, and send to everyone listed in those lists.
2210The
2211.q Bcc:
2212line will be deleted before sending.
2213Any addresses in the argument vector will be deleted
2214from the send list.
2215.ip \-a\&m
2216Do special processing for the
2217ARPANET.
2218This includes reading the
2219.q "From:"
2220line from the header to find the sender,
2221printing
2222ARPANET
2223style messages
2224(preceded by three digit reply codes for compatibility with
2225the FTP protocol
2226[Neigus73, Postel74, Postel77]),
2227and ending lines of error messages with <CRLF>.
2228.ip \-a\&f
2229Same as
2230.b \-a\&m ,
2231except print out message numbers appropriate for the MLFL command
2232[Postel77].
2233.ip \-s
2234Save UNIX-style
2235.q From
2236lines at the beginning of headers.
2237Normally they are assumed redundant
2238and discarded.
2239.ip \-v
2240Give a blow-by-blow description of function.
2241This gives information of interest to the user
2242rather than for the
2243.i sendmail
2244maintainer;
2245for example,
2246aliases are printed as expanded
2247and mailer functions are printed as they run.
2248.ip \-C\&file
2249Use a different configuration file.
2250.ip \-A\&file
2251Use a different alias file.
2252.ip \-I
2253Initialize the DBM version
2254of the alias file.
2255If
2256.b \-I
2257is given,
2258no delivery is attempted.
2259The DBM version will be rebuilt automatically if the DBM files
2260are mode 666,
2261or if they are owned by the effective userid.
2262.ip \-V
2263Verify the addresses only.
2264Only partial verification is done:
2265syntax is checked, and local names are verified,
2266but no checking normally done by the mailer is attempted.
2267.ip \-d\&level
2268Set debugging level.
2269.ip \-D\&x\&val
2270Define macro
2271.i x
2272to have value
2273.i val .
2274.nr ii 5n
2275.+c "OTHER CONFIGURATION"
2276.pp
2277There are some configuration changes that can be made by
2278recompiling
2279.i sendmail .
2280Some of these are changes to compilation flags:
2281.nr ii 1i
2282.ip V6
2283If set,
2284this will compile a version 6 system,
2285with 8-bit user id's,
2286single character tty id's,
2287etc.
2288If not set,
2289a version 7 system is assumed.
2290.ip DBM
2291If set,
2292the
2293.q DBM
2294package in UNIX is used
2295(see DBM(3X) in [UNIX80]).
2296If not set,
2297a much less efficient algorithm for processing aliases is used.
2298.ip VFORK
2299Set if your system has the experimental
2300.i vfork
2301system call.
2302See vfork(2) in [UNIX80].
2303If not set,
2304the regular
2305.i fork
2306system call is used.
2307This option improves performance.
2308.ip DEBUG
2309If set, debugging information is compiled in.
2310To actually get the debugging output,
2311the
2312.b \-d
2313flag must be used.
2314.ip LOG
2315If set,
2316the
2317.i syslog
2318routine in use at some Berkeley sites is used.
2319This logs an informational log record
2320for each message processed,
2321and logs a higher priority log record
2322for internal system errors.
2323.ip NEWFTP
2324If set, the ARPANET reply codes for
2325.q "Revised New FTP"
2326are used
2327[Postel74].
2328If not set,
2329reply codes for the old, unrevised
2330.q "New FTP"
2331are used
2332[Neigus73].
2333If you want to use reply codes for the Mail Transfer Protocol
2334[Sluizer81]
2335you may find it necessary to make some code modifications.
2336.ip PARANOID
2337There are places where
2338.i sendmail
2339may opt for a more secure,
2340but probably less convenient environment.
2341For example,
2342if this flag is set
2343it is not possible to specify a program as an address directly;
2344this can only be done with an alias.
2345.ip NOTUNIX
2346If you are using a non-UNIX mail format,
2347you can set this flag to turn off special processing
2348of UNIX-style
2349.q "From "
2350lines.
2351.nr ii 5n
2352.pp
2353If you want to enable special processing of other headers,
2354you will have to add them to the
2355.i HdrInfo
2356table in
2357.i conf.c .
2358This table contains the header name
2359(which should be in all lower case),
2360a set of header control flags (described below),
2361and a set of mailer flags,
2362used by some of the header flags.
2363The header flags are:
2364.nr ii \w'H_ACHECK  'u
2365.ip H_CHECK
2366Check the flags for the receiving mailer
2367against the third field in the
2368.i HdrInfo
2369entry.
2370If the mailer has any of those bits set,
2371send this field;
2372otherwise, do not send this field to that mailer.
2373If the field was in the message originally, however,
2374it will always be sent
2375(i.e., this only applies to headers being added by
2376.i sendmail ).
2377.ip H_ACHECK
2378Same as H_CHECK,
2379except that it even applies to headers that were in the
2380original message.
2381That is,
2382if this bit is set and the mailer does not have flag bits set
2383that intersect with the third field in this
2384.i HdrInfo
2385entry,
2386the header line is
2387.i always
2388deleted.
2389.ip H_EOH
2390If this header field is set,
2391treat it like a blank line,
2392i.e.,
2393it will signal the end of the header
2394and the beginning of the message text.
2395.ip H_FORCE
2396Add this header entry
2397even if one existed in the message before.
2398If a header entry does not have this bit set,
2399.i sendmail
2400will not add another header line if a header line
2401of this name already existed.
2402This would normally be used to stamp the message
2403by everyone who handled it.
2404.ip H_ADDR
2405If set,
2406this field contains recipient addresses.
2407This is used by the
2408.b \-t
2409flag to determine who to send to
2410when it is collecting recipients from the message.
2411.nr ii 5n
2412.lp
2413Let's look at a sample
2414.i HdrInfo
2415specification:
2416.(b
2417.sz -2
2418.ta 4n +\w'"received-from",  'u +\w'H_ADDR|H_ACHECK,  'u
2419struct hdrinfo	HdrInfo[] =
2420{
2421	"date",	H_CHECK,	M_NEEDDATE,
2422	"from",	H_CHECK,	M_NEEDFROM,
2423	"original-from",	H_ACHECK,	0,
2424	"sender",	0,	0,
2425	"full-name",	H_ACHECK,	M_FULLNAME,
2426	"to",	H_ADDR,	0,
2427	"cc",	H_ADDR,	0,
2428	"bcc",	H_ADDR|H_ACHECK,	0,
2429	"message-id",	H_CHECK,	M_MSGID,
2430	"message",	H_EOH,	0,
2431	"text",	H_EOH,	0,
2432	"received-date",	H_CHECK,	M_LOCAL,
2433	"received-from",	H_CHECK,	M_LOCAL,
2434	"via",	H_FORCE,	0,
2435	NULL,	0,	0,
2436};
2437.sz
2438.)b
2439This specification says that the
2440.q Date: ,
2441.q From: ,
2442.q Message-Id: ,
2443.q Received-Date: ,
2444and
2445.q Received-From:
2446must be requested by the mailer to be inserted.
2447However,
2448if they were in the message as received by
2449.i sendmail
2450they will be propagated.
2451The
2452.q Full-Name:
2453field, on the other hand,
2454will be deleted even if it was specified before,
2455unless the mailer wants it.
2456The
2457.q Original-From:
2458and
2459.q Bcc:
2460fields will be deleted unconditionally
2461(since it is never possible for a mailer's flags
2462to intersect with zero).
2463The
2464.q Original-From:
2465is in fact used internally,
2466and will be reinserted by ad hoc code,
2467but only if it differs from the
2468.q From:
2469line that would otherwise be inserted.
2470.q To: ,
2471.q Cc: ,
2472and
2473.q Bcc:
2474all specify recipient addresses.
2475The
2476.q Message:
2477and
2478.q Text:
2479fields will terminate the header;
2480these are specified in new protocols
2481[NBS80]
2482or used by random dissenters around the network world.
2483The
2484.q Via:
2485field will always be added,
2486and can be used to trace messages.
2487The
2488.q Sender:
2489field is used internally,
2490although no cliched special processing occurs.
2491.pp
2492There are a number of important points here.
2493First,
2494header fields are not added automatically just because they are in the
2495.i HdrInfo
2496structure;
2497they must be specified in the configuration file
2498in order to be added to the message.
2499Any header fields mentioned in the configuration file but not
2500mentioned in the
2501.i HdrInfo
2502structure have default processing performed;
2503that is,
2504they are added unless they were in the message already.
2505Second,
2506the
2507.i HdrInfo
2508structure only specifies cliched processing;
2509certain headers are processed specially by ad hoc code
2510regardless of the status specified in
2511.i HdrInfo .
2512For example,
2513the
2514.q Sender:
2515and
2516.q From:
2517fields are always scanned on ARPANET mail
2518to determine the sender;
2519this is used to perform the
2520.q "return to sender"
2521function.
2522The
2523.q "From:"
2524and
2525.q "Full-Name:"
2526fields are used to determine the full name of the sender
2527if possible;
2528this is stored in the macro
2529.b $x
2530and used in a number of ways.
2531Although the
2532.q "Original-From:"
2533field is specified to be deleted in
2534.i HdrInfo ,
2535it is added automatically if the
2536.q From:
2537field that would be generated internally
2538differs from the
2539.q From:
2540field that was specified in the message;
2541in this case,
2542the original
2543.q From:
2544field is renamed
2545.q Original-From: .
2546.pp
2547The file
2548.i conf.c
2549also contains the specification of ARPANET reply codes.
2550There are six classifications these fall into:
2551.(b
2552.sz -2
2553.ta \w'char  'u +\w'Arpa_Usrerr[] =  'u +\w'"888";  'u
2554char	Arpa_Info[] =	"050";	/* arbitrary info */
2555char	Arpa_Enter[] =	"350";	/* start mail input */
2556char	Arpa_Mmsg[] =	"256";	/* mail successful (MAIL cmd) */
2557char	Arpa_Fmsg[] =	"250";	/* mail successful (MLFL cmd) */
2558char	Arpa_Syserr[] =	"455";	/* some (transient) system error */
2559char	Arpa_Usrerr[] =	"450";	/* some (fatal) user error */
2560.sz
2561.)b
2562The class
2563.i Arpa_Info
2564is for any information that is not required by the protocol,
2565such as forwarding information.
2566.i Arpa_Enter
2567is output when
2568.i sendmail
2569wants to start receiving the mail.
2570.i Arpa_Mmsg
2571and
2572.i Arpa_Fmsg
2573are given if the mail is successfully delivered;
2574the selection of message number depends on the FTP command given
2575(which is communicated via the
2576.b \-a
2577flag).
2578.i Arpa_Syserr
2579is printed by the
2580.i syserr
2581routine;
2582typically, this occurs when something has gone wrong at the
2583receiving site,
2584with the assumption that it is a transient condition.
2585Finally,
2586.i Arpa_Usrerr
2587is the result of a user error
2588and is generated by the
2589.i usrerr
2590routine;
2591these are generated when the user has specified something wrong,
2592and hence the error is permanent,
2593i.e.,
2594it will not work simply by resubmitting the request.
2595.pp
2596If it is necessary to restrict mail through a gateway,
2597the
2598.i checkcompat
2599routine can be modified.
2600This routine is called for every recipient address.
2601It can return
2602.b TRUE
2603to indicate that the address is acceptable
2604and mail processing will continue,
2605or it can return
2606.b FALSE
2607to reject the recipient.
2608If it returns false,
2609it is up to
2610.i checkcompat
2611to print an error message
2612(using
2613.i usrerr )
2614saying why the message is rejected.
2615For example,
2616.i checkcompat
2617could read:
2618.(b
2619.re
2620.sz -2
2621bool
2622checkcompat(to)
2623	register ADDRESS *to;
2624{
2625	if (MsgSize > 50000 && to->q_mailer != MN_LOCAL)
2626	{
2627		usrerr("Message too large for non-local delivery");
2628		return (FALSE);
2629	}
2630	return (TRUE);
2631}
2632.sz
2633.)b
2634This would reject messages greater than 50000 bytes
2635unless they were local.
2636The actual use of this routine is highly dependent on the
2637implementation,
2638and use should be limited.
2639