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.4,
25last modified on 08/31/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[Schoens79],
76BerkNet mail
77[Schmidt99],
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[Ether99]),
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[MH99],
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 the 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.sh 2 "Aliasing, Forwarding, Inclusion"
531.pp
532.i Sendmail
533reroutes mail three ways.
534Aliasing applies system wide.
535Forwarding allows each user to reroute incoming mail
536destined for that account.
537Inclusion directs
538.i sendmail
539to read a file for a list of addresses,
540and is normally used
541in conjunction with aliasing.
542.sh 3 "Aliasing"
543.pp
544Aliasing maps names to address lists using a system-wide file.
545This file is inverted to speed access.
546Only names that parse as local
547are allowed as aliases;
548this guarantees a unique key.
549.pp
550The inverted form of the file
551must be recreated when the text copy is changed.
552The
553.b \-I
554option to
555.i sendmail
556rebuilds the database\**.
557.(f
558\**This could be done automatically if
559.i sendmail
560could be guaranteed to be running as the owner of the
561alias file.
562In some environments this is not the case.
563.)f
564.sh 3 "Forwarding"
565.pp
566After aliasing,
567users that are local and valid
568are checked for the existence of a
569.q .forward
570file in their home directory.
571If it exists,
572the message is
573.i not
574sent to that user,
575but rather to the list of users in that file.
576The expectation is that this will normally
577be one user only,
578and the use will be for network mail forwarding.
579.pp
580Forwarding also permits a user to specify a private incoming mailer.
581For example,
582forwarding to:
583.(b
584"\^|\|/usr/local/newmail myname"
585.)b
586will use a different incoming mailer.
587.sh 3 "Inclusion"
588.pp
589Inclusion is specified in ARPANET syntax:
590.(b
591:Include: pathname
592.)b
593An address of this form reads the file specified by
594.i pathname
595and sends to all users listed in that file.
596.pp
597The intent is
598.i not
599to support direct use of this feature,
600but rather to use this as a subset of aliasing.
601For example,
602an alias of the form:
603.(b
604project: :include:/usr/project/userlist
605.)b
606is a method of letting a project maintain a mailing list
607without interaction with the system administration,
608even if the alias file is protected.
609.pp
610It is not necessary to rebuild the alias database
611when a :include: list is changed.
612.sh 2 "Exit Status"
613.pp
614An exit status is returned that corresponds to the system standard
615used by the other mailers.
616.sh 2 "Interaction With Other Mailers"
617.pp
618Two examples of how network-specific work is passed to other programs
619are the incoming UUCP mailer
620(\c
621.i rmail )
622and the outgoing ARPANET mailer.
623.sh 3 "Incoming UUCP mail"
624.pp
625Mail coming in from the UUCP network
626is not guaranteed to have a normal header line,
627nor will an argument be passed telling who it is from\**.
628.(f
629\**As a result of this,
630it is impossible to verify UUCP sender addresses.
631.)f
632Fortuitously,
633UUCP mail calls the program
634.i rmail
635rather than
636.i mail
637or
638.i sendmail .
639The
640.i rmail
641program has been modified here to do the special-purpose parsing
642necessary to decode UUCP headers
643and turn them into a normal UUCP address;
644this address is then passed to
645.i sendmail
646via a
647.b \-f
648flag.
649.sh 3 "Outgoing ARPANET mail"
650.pp
651The ARPANET imposes many standards that
652.i sendmail
653does not care to enforce.
654For example,
655an arpanet sitename must be on
656.i every
657address,
658not just the
659.q "From:"
660address.
661Certain UNIX sites like to use
662.q %
663as an alternative to
664.q @ ,
665which must be translated.
666The outgoing ARPANET mailer makes these transformations
667before passing the message to the network.
668.sh 1 CONFIGURATION
669.pp
670Configuration is controlled primarily by the file
671.i /usr/lib/sendmail.cf .
672.i Sendmail
673should not need to be recomplied except
674.np
675To change operating systems
676(V6, V7/32V, 4BSD).
677.np
678To remove or insert the DBM library.
679.np
680To change ARPANET reply codes.
681.np
682To add headers requiring special processing.
683.lp
684Adding mailers or changing parsing or routing information
685does not require recompilation.
686.pp
687If the mail is being sent by a local user,
688and the file
689.q .mailcf
690exists in the sender's home directory,
691that file is read as a configuration file
692after the system configuration file.
693The primary use of this is to add header lines.
694.sh 2 "Configuration File Description"
695.pp
696The configuration file is formatted
697as a series of text lines,
698each beginning with a character describing its semantics.
699Blank lines and lines beginning with a sharp sign
700(#)
701are ignored.
702Other lines are:
703.(b
704.ta 3n
705D	define macro
706H	define header
707M	define mailer
708S	use rewriting set
709C	define word class
710R	specify rewriting rule
711.)b
712.pp
713See figure 2 for an example configuration file.
714.(z
715.hl
716.sz -2
717.re
718##########################################
719# sendmail configuration file
720#	@(#)sendmail.cf	3.6	8/17/81
721##########################################
722.sp \n(psu
723### local hosts on various nets
724DABerkeley
725DBIngVAX
726DUucbvax
727.sp \n(psu
728### special macros
729# my name
730D\&n\&MAILER-DAEMON
731# UNIX header format
732D\&l\&From $g  $d
733# delimiter (operator) characters
734D\&o\&.:@!^
735.sp \n(psu
736### format of headers:
737H\&Date: $a
738H\&From: $g$?x ($x)$.
739H\&Full-Name: $x
740H\&Message-Id: <$t.$p.$B@$A>
741H\&Posted-Date: $a
742.sp \n(psu
743### name classifications
744# arpanet hostnames
745C\&A\&ucb berkeley
746# list of local host names
747C\&B\&j IngVax
748# berknet hosts on the arpanet
749C\&C\&i ingres ing70
750# uucp hostnames
751C\&U\&ucbvax ernie
752.sp \n(psu
753.ta \w'M\&local  'u +\w'/usr/net/bin/sendberkmail  'u +\w'rlsAmn  'u +\w'$f@$A  'u
754###  mailers
755# local mail -- must be zero
756M\&local	/bin/mail	rlsAmn	$f	...local\&mail -d $u
757# program mail -- must be one
758M\&prog	/bin/csh	lA	$f	...prog\&mail -fc $u
759# berkeley net mail
760M\&berk	/usr/net/bin/sendberkmail	fxs	$B:$f	...berk\&mail -m $h -h $c -t $u
761# arpanet mail
762M\&arpa	/usr/lib/mailers/arpa	sAu	$f@$A	...arpa\&mail $f $h $u
763# uucp mail
764M\&uucp	/usr/bin/uux	rsDxm	$U!$f	...uucp\&mail - $h!rmail ($u)
765.sp \n(psu
766### rewriting rules
767.ta \w'R\&CSVAX:$-h!$+u  'u +\w'$#berk$@ing70$:$+u@$+h  'u
768R\&$-h.$+u	$+h:$+u	change "." to ":"
769R\&$=C:$+u@$-h	$+u@$+h	delete ing70: on arpanet addresses
770R\&$+u@$=A	ing70:$+u	delete local arpa hosts
771R\&$+u@$-h	$#berk$@ing70$:$+u@$+h	send arpa mail to ing70
772R\&$+h^$+u	$+h!$+u	change "^" to "!"
773R\&$-x!$=U!$+y	csvax:$+y	delete uucp loops through csvax
774R\&$-h!$+u	csvax:$+h!$+u	send uucp mail to csvax
775R\&$-x:$-h:$+u	$+h:$+u	delete multiple berk hosts
776R\&$=B:$+u	$+u	delete local berk hosts
777R\&$-h:$+u	$#berk$@$+h$:$+u	resolve berk mail
778R\&$+u	$#local$:$+u	resolve local mail
779.sp \n(psu
780### rewriting rules for from host
781S\&1
782R\&ing70:$+u@$-h	$+u@$+h	arpanet mail is automatic
783R\&CSVAX:$-h!$+u	$+h!$+u	uucp mail is automatic
784.sz
785.sp
786.ce
787Figure 2.  Sample configuration file.
788.hl
789.)z
790.sh 3 "D \*- define macro"
791.(b
792.b D \c
793.i x\|val
794.)b
795.pp
796This line defines a macro
797with the single character name
798.i x
799and value
800.i val .
801Macros can be interpolated using the escape
802.b $ \c
803.i x ,
804where
805.i x
806is the macro name.
807By convention,
808all upper-case letters are unused by
809.i sendmail
810and may be used freely by the user;
811all other names are reserved for use by sendmail.
812Certain macros
813.i must
814be defined,
815and are used internally.
816These are:
817.(b
818.ta 4n
819$l	UNIX-style \*(lqFrom\*(rq line.
820$n	My address in error messages.
821$o	\*(lqOperators\*(rq in addresses.
822.)b
823The
824.b $l
825macro is expanded when
826.i sendmail
827wants to insert a UNIX-style
828.q From
829line on messages.
830This typically expands to something like:
831.(b
832From sally  Wed Aug 12 09:15:13 1981
833.)b
834The
835.b $n
836macro is used as the name of this process
837when error messages are being mailed back.
838Typically,
839it is wise to include an alias
840so that mail to this address will be sent to root.
841The
842.b $o
843macro defines the characters
844that will separate words when addresses are being broken up.
845Each of these becomes a word by itself when scanned.
846Blanks and tabs are built-in separators
847but are ignored,
848i.e., are not turned into words.
849For example, the input:
850.(b
851Ing70:  ZRM  @  MIT-MC  SRI-KL
852.)b
853Is broken up into the six words:
854.(b
855Ing70, :, ZRM, @, MIT-MC, SRI-KL
856.)b
857assuming that colon and at-sign are operators
858(but hyphen is not).
859.pp
860A number of macros are defined by
861.i sendmail
862for use as primitives.
863These are:
864.(l
865.ta 5n
866$a	The \*(lqDate:\*(rq line date in ARPANET format.
867$b	The current date in ARPANET format.
868$c	The hop count.
869$d	The date in UNIX (ctime) format.
870$f	The sender's (from) address.
871$g	The sender's address translated by the mailer.
872$h	The host of the recipient.
873$p	The process id of sendmail in decimal.
874$t	The time in seconds in decimal.
875$u	The user part of the recipient.
876$v	The version number of sendmail.
877$x	The full name of the sender.
878$y	The id of the sender's terminal.
879$z	The home directory of the recipient.
880.)l
881.pp
882There are three types of dates that can be used.
883The
884.b $a
885and
886.b $b
887macros are in ARPANET format;
888.b $a
889is a copy of the time extracted from the
890.q Date:
891field of the incoming message
892(if there was one),
893and
894.b $b
895is the current date and time \*- used for postmarks.
896If no
897.q Date:
898is found in the message,
899they are the same.
900The
901.b $d
902macro has the date in UNIX
903.i ctime
904format;
905this is extracted from the message if possible
906and is otherwise the current date.
907.pp
908The
909.b $f
910macro is the id of the sender
911as originally determined;
912when mailing to a specific person,
913the
914.b $g
915macro is the address of the sender
916with respect to the receiver.
917For example,
918if I send to
919.q csvax:samwise
920the
921.b $f
922and
923.b $g
924macros are:
925.(b
926.ta 4n
927$f	eric
928$g	IngVAX:eric
929.)b
930This only applies to the first step in the link.
931For example,
932sending to Ing70:drb@bbn-unix,
933we have
934.b $f
935and
936.b $g
937as above for the transfer to Ing70, but:
938.(b
939$f	IngVAX:eric
940$g	IngVAX:eric@Berkeley
941.)b
942for transfer to the ARPANET.
943.pp
944The
945.b $x
946macro is set to the full name of the sender.
947This can be determined in several ways.
948If a
949.b \-F
950flag is given to
951.i sendmail ,
952this value is taken as the full name.
953The
954.q Full-Name:
955line in the header is the second option,
956and the comment portion of the
957.q From:
958line is the third.
959If all of these fail,
960and if the message is being originated locally,
961the full name is looked up in the
962.i passwd
963file.
964.pp
965When sending, the
966.b $u ,
967.b $h ,
968and
969.b $z
970macros get set to the user, host, and home directory
971(respectively)
972of the receiver.
973The host is only set if the user is not local,
974and the home directory is only set if the user is local.
975.pp
976The
977.b $p
978and
979.b $t
980macros are used to create unique strings.
981The
982.b $y
983macro is set to the id of the terminal of the sender
984(if known);
985some systems like to put this in the
986.q From
987line.
988The
989.b $v
990macro is set to the version number of
991.i sendmail ,
992and can be used in postmarks
993to help debugging.
994.pp
995A primitive conditional is available during macro expansion.
996The construct:
997.(b
998$?x text1 $: text2 $.
999.)b
1000tests if macro
1001.b $ \c
1002.i x
1003is defined.
1004If it is,
1005text1 is interpolated;
1006otherwise,
1007text2 is interpolated.
1008.sh 3 "H \*- define header"
1009.(b
1010.b H \c
1011.i "Field-Name" \c
1012.b ":" " \c
1013.i "field value"
1014.)b
1015.pp
1016The
1017.b H
1018line looks like a regular header line,
1019except that the field value is macro expanded
1020before use.
1021All headers mentioned in this way
1022are automatically inserted
1023into every message
1024except for headers mentioned in the compile-time
1025configuration file
1026.i conf.c .
1027These headers are
1028Date,
1029From,
1030Full-Name,
1031Message-Id,
1032and
1033Received-Date.
1034To get these fields the appropriate flag
1035must be specified
1036for the receiving mailer.
1037.pp
1038Since the file
1039.q ".mailcf"
1040in the sender's home directory is read and processed,
1041it is possible to add customized header lines.
1042For example,
1043the .mailcf consisting of:
1044.(b
1045H\&Phone: (415) 888-9990
1046.)b
1047will add that line to every outgoing message.
1048.sh 3 "M \*- define mailer"
1049.(b F
1050.b M \c
1051.i mailer-name
1052.i pathname
1053.i flags
1054.i from-macro
1055.i "argument list"
1056.)b
1057.pp
1058This line is structured into fields
1059separated by white space (spaces or tabs).
1060The fields are:
1061.np
1062The internal name of the mailer,
1063referred to in the rewriting rules.
1064.np
1065The pathname of the program to execute for this mailer.
1066.np
1067The flags for this mailer,
1068described below.
1069.np
1070The macro string to become the
1071.b $g
1072macro (translated sender)
1073for this mailer.
1074.np
1075The argument vector passed to the mailer
1076(macro expanded).
1077.pp
1078The flags are a series of characters:
1079.ls 1
1080.ip f
1081The mailer wants a
1082.b \-f
1083.i from
1084flag,
1085but only if this is a network forward operation
1086(i.e.,
1087the mailer will give an error
1088if the executing user does not have special permissions).
1089.ip r
1090Same as
1091.b f ,
1092but sends a
1093.b \-r
1094flag.
1095.ip q
1096Don't print errors \*- the mailer will do it for us.
1097.ip S
1098Don't reset your userid before calling the mailer.
1099This would be used in a secure environment where
1100.i sendmail
1101ran as a special user.
1102This could be used to prevent
1103(or at least complicate)
1104forged addresses.
1105This option is suppressed in
1106.q unsafe
1107configuration files
1108(i.e., user-supplied, either on a
1109.b \-C
1110option, or in the
1111.i \&.mailcf
1112file in the home directory).
1113.ip n
1114This mailer does not want a UNIX-style
1115.q From
1116line on the message.
1117.ip l
1118This mailer is local,
1119so no host will be specified.
1120Also,
1121the mailer wants special local processing
1122(such as a
1123.q Received-Date:
1124field).
1125.ip s
1126Strip quote characters off of addresses
1127before calling the mailer.
1128.ip m
1129This mailer can send to multiple users
1130(on the same host)
1131in one call.
1132.ip F
1133This mailer wants a
1134.q From:
1135header line.
1136.ip D
1137This mailer wants a
1138.q Date:
1139header line.
1140.ip M
1141This mailer wants a
1142.q Message-Id:
1143header line.
1144.ip x
1145This mailer wants a
1146.q Full-Name:
1147header line.
1148.ip u
1149Upper case should be preserved in user names.
1150.ip h
1151Upper case should be preserved in host names.
1152.ip A
1153This mailer wants an ARPANET standard header
1154(equivalent to the
1155.b F
1156and
1157.b D
1158flags).
1159.ls
1160.sh 3 "S \*- use rewriting set"
1161.(b
1162.b S \c
1163.i N
1164.)b
1165.pp
1166There are two sets of rewriting rules.
1167Set zero is used to rewrite recipient addresses.
1168Set one is used to rewrite sender addresses.
1169Set one can be used to eliminate implicit links.
1170For example,
1171if there exists a site on on the BerkNet called
1172.q Ing70
1173which is an ARPANET gateway,
1174and we are on a site called
1175.q IngVAX ,
1176ARPANET mail coming into
1177.q Ing70
1178for someone on
1179.q IngVAX
1180will read:
1181.(b
1182From: Ing70:auser@ahost
1183.)b
1184Rewriting set one can rewrite this as:
1185.(b
1186From: auser@ahost
1187.)b
1188since
1189.q Ing70
1190will be implied.
1191.pp
1192When you change to a new set,
1193the previous content of that set is cleared.
1194.sh 3 "R \*- rewriting rule"
1195.(b F
1196.b R \c
1197.i pattern
1198.i replacement
1199.i comments
1200.)b
1201.pp
1202The rewriting rules drive the address parser.
1203The rewriting process is essentially textual.
1204First,
1205the address to be rewritten is broken up into words.
1206Words are defined as strings of non-special characters
1207separated by white space or single special characters
1208as defined by the
1209.b $o
1210macro.
1211Then,
1212the words are rewritten using simple pattern matching.
1213Words in the pattern match themselves
1214unless they begin with dollar sign.
1215The dollar escapes have the following meanings\**:
1216.(f
1217\**These dollar escapes have nothing to do with macro expansion.
1218.)f
1219.(b
1220.ta 6n
1221$-x	Match a single word (and call it x).
1222$+x	Match one or more words (and call them x).
1223$=c	Match any word in class c (see below).
1224.)b
1225The case of letters is ignored in pattern matching
1226(including class comparisons).
1227.pp
1228When a pattern (also called a left hand side or LHS)
1229matches,
1230the input is rewritten as defined by the right hand side (RHS).
1231Acceptable escapes in the RHS are:
1232.(b
1233.ta \w'$#mailer  'u
1234$+x	Replace from corresponding match in LHS.
1235$#mailer	Canonical mailer name.
1236$@host	Canonical host name.
1237$:user	Canonical user name.
1238.)b
1239The replacement from the LHS to the RHS does not use macros,
1240and there are no name conflicts.
1241Patterns are reexecuted until it fails.
1242As soon as the input resolves to a canonical name
1243(i.e.,
1244.q "$#mailer$@host$:user" ),
1245rewriting ends;
1246otherwise,
1247the next pattern is tried.
1248The
1249.q "$@host"
1250part is not needed
1251if the mailer does not require a host.
1252The special mailer
1253.q error
1254causes the user part to be printed as an error.
1255.sh 3 "C \*- define word class"
1256.(b F
1257.b C \c
1258.i c\|word\&1
1259.i word\&2 ...
1260.)b
1261.pp
1262There are twenty six word classes,
1263represented as
1264.q A
1265through
1266.q Z .
1267For example:
1268.(b
1269CVcsvax ingvax esvax
1270.)b
1271defines the words
1272.q csvax ,
1273.q ingvax ,
1274and
1275.q esvax
1276to all be in class
1277.q V ,
1278so that
1279.q $=V
1280on the LHS of a rewriting rule
1281will match any of these words.
1282.sh 2 "A Detailed Example"
1283.pp
1284We will now follow the configuration file
1285in figure 2
1286through in detail.
1287.sh 3 "Macro definitions"
1288.(b
1289DABerkeley
1290DBIngVAX
1291DUucbvax
1292DnMAILER-DAEMON
1293DlFrom $g  $d
1294Do.:@!^
1295.)b
1296The first three macros are for convenience only,
1297and are used to define the local host names
1298on the ARPANET, BerkNet, and the UUCP net
1299respectively.
1300.pp
1301Macro
1302.b n
1303defines the name of
1304.i sendmail
1305when error messages are sent.
1306Macro
1307.b l
1308defines what the first line
1309of a message in UNIX format looks like,
1310in this case the version 7 standard of:
1311.(b
1312From sender-name  time-of-submission
1313.)b
1314The
1315.b o
1316macro
1317tells what characters will be distinct from names
1318when scanning addresses.
1319In this case,
1320dot and colon will be used
1321to distinguish BerkNet addresses,
1322at sign for ARPANET addresses,
1323and exclamation point and caret for UUCP addresses.
1324.sh 3 "Header definitions"
1325.(b
1326H\&Date: $a
1327H\&From: $g$?x ($x)$.
1328H\&Full-Name: $x
1329H\&Message-Id: <$t.$p.$B@$A>
1330H\&Posted-Date: $a
1331.)b
1332These define the headers
1333that may be added to a message.
1334The
1335.q Date:
1336is just the ARPANET idea of the date.
1337The
1338.q From:
1339line is the translated version of the sender,
1340followed by the sender's full name if known.
1341The
1342.q Full-Name:
1343field is used to transmit the sender's full name
1344when a
1345.q From:
1346line is not being sent;
1347these will normally be mutually exclusive.
1348The
1349.q Message-Id:
1350field has the time and process id's concatenated
1351with the BerkNet and ARPANET addresses
1352to make a unique string.
1353Finally, the
1354.q Posted-Date:
1355is the date in ARPANET format;
1356it differs from
1357.q Date:
1358in that it is always output as soon as the message enters
1359.i sendmail 's
1360domain,
1361and hence indicates the time that the message first enters
1362the mail delivery system
1363[Postel79b, NBS80].
1364.sh 3 "Name classifications"
1365.(b
1366C\&A\&ucb berkeley
1367C\&B\&j IngVax
1368C\&C\&i ingres ing70
1369C\&U\&ucbvax ernie
1370.)b
1371These commands put the words
1372.q ucb
1373and
1374.q berkeley
1375into class
1376.q A ,
1377the valid names of this site on the ARPANET.
1378Words
1379.q j
1380and
1381.q ingvax
1382are in class
1383.q B ,
1384the local names on BerkNet.
1385Class
1386.q C ,
1387the names of the site which has the ARPANET link,
1388has the words
1389.q i ,
1390.q ingres ,
1391and
1392.q ing70 .
1393Finally,
1394.q ucbvax
1395and
1396.q ernie
1397are the UUCP names of our UUCP gateway,
1398and are in class
1399.q U .
1400.pp
1401The classes will be used in the patterns of the rewriting rules
1402as described below.
1403.sh 3 "Mailer definitions"
1404.(b
1405.sz -2
1406.ta \w'M\&local  'u +\w'/usr/net/bin/sendberkmail  'u +\w'rlsAmn  'u +\w'$f@$A  'u
1407M\&local	/bin/mail	rlsAmn	$f	...localmail -d $u
1408M\&prog	/bin/csh	lA	$f	...progmail -fc $u
1409M\&berk	/usr/net/bin/sendberkmail	fxs	$B:$f	...berkmail -m $h -h $c -t $u
1410M\&arpa	/usr/lib/mailers/arpa	sAu	$f@$A	...arpamail $f $h $u
1411M\&uucp	/usr/bin/uux	rsDxm	$U!$f	...uucpmail - $h!rmail ($u)
1412.sz
1413.)b
1414Five mailers are known in the configuration file.
1415The first two
1416.i must
1417be for local and program mail,
1418and must come as the first and second mailers respectively.
1419.pp
1420Local mail is sent using
1421/bin/mail.
1422It takes a
1423.b \-r
1424flag,
1425is local,
1426quote characters are stripped before sending,
1427takes ARPANET standard headers,
1428can deliver to multiple recipients at once,
1429and does not want a UNIX-style
1430.q From
1431line since it will add one itself.
1432The translated from address is the same as the raw from address,
1433since no network hops are made.
1434The argument vector has a program name,
1435a
1436.b \-d
1437flag (\c
1438.q "really deliver" ,
1439which must be added to /bin/mail),
1440and the list of recipients \*- one recipient per argument.
1441.pp
1442Mail piped through programs
1443is interpreted by /bin/csh.
1444Unlike local mail,
1445it does not take a
1446.b \-r
1447flag,
1448quotes should be left,
1449it can only deal with one user,
1450and it does want a UNIX-style
1451.q From
1452line,
1453but is still local and still wants an ARPANET style header.
1454.pp
1455BerkNet mail is processed by
1456/usr/net/bin/sendberkmail.
1457It takes a
1458.b \-f
1459flag,
1460wants a
1461.q Full-Name:
1462header line,
1463and wants quotes stripped.
1464The
1465.q Full-Name:
1466is used here because if it were given as a comment
1467in a
1468.q From:
1469line the machine address of the sender
1470would not be modified by later instantiations of
1471.i delivermail \**.
1472.(f
1473\**\c
1474.i Delivermail
1475did no header editing,
1476so
1477.q From:
1478lines were always passed untouched.
1479When the gateways are converted to
1480.i sendmail
1481this can be changed.
1482.)f
1483The from address as seen by the receiver is
1484.q IngVAX:sender ,
1485and it takes a flag-oriented
1486rather than a positional
1487command list.
1488.pp
1489The ARPANET wants quotes stripped,
1490ARPANET standard headers,
1491and wants the user name left with case intact.
1492It takes a positional command list.
1493.pp
1494UUCP mail calls
1495.i uux
1496with a
1497.b \-r
1498flag,
1499quotes stripped,
1500a
1501.q Date:
1502line,
1503a
1504.q Full-Name:
1505line,
1506and with multiple users listed.
1507.sh 3 "Rewriting rules for recipient addresses"
1508.(b
1509.sz -2
1510.ta \w'[99]  'u +\w'R\&CSVAX:$-h!$+u  'u +\w'$#berk$@ing70$:$+u@$+h  'u
1511[1]	R\&$-h.$+u	$+h:$+u	change "." to ":"
1512[2]	R\&$=C:$+u@$-h	$+u@$+h	delete ing70: on arpanet addresses
1513[3]	R\&$+u@$=A	ing70:$+u	delete local arpa hosts
1514[4]	R\&$+u@$-h	$#berk$@ing70$:$+u@$+h	send arpa mail to ing70
1515[5]	R\&$+h^$+u	$+h!$+u	change "^" to "!"
1516[6]	R\&$-x!$=U!$+y	csvax:$+y	delete uucp loops through csvax
1517[7]	R\&$-h!$+u	csvax:$+h!$+u	send uucp mail to csvax
1518[8]	R\&$-x:$-h:$+u	$+h:$+u	delete multiple berk hosts
1519[9]	R\&$=B:$+u	$+u	delete local berk hosts
1520[10]	R\&$-h:$+u	$#berk$@$+h$:$+u	resolve berk mail
1521[11]	R\&$+u	$#local$:$+u	resolve local mail
1522.sz
1523.)b
1524The first rule translates dots to colons.
1525Redundant explicit routing to the ARPANET is deleted
1526in the second rule.
1527Hops out over the ARPANET
1528back to us are deleted in the third rule \*-
1529note that the BerkNet host that we would have come in on
1530is inserted.
1531Real ARPANET mail is resolved immediately with no further ado \*-
1532it is sent out over the BerkNet to the ing70,
1533and further rewriting stops immediately.
1534.pp
1535Carets are changed to exclamation points
1536for UUCP addresses in the fifth rule.
1537The sixth rule deletes loops out into UUCP land
1538and back to us \*- noting that we will be left on CSVAX.
1539Multiple BerkNet hosts are deleted in rule seven \*-
1540this can occur internally quite easily
1541as a side effect of a rewriting rule.
1542Rule eight deletes local BerkNet hosts.
1543The last two rules resolve BerkNet and local mail.
1544.pp
1545Consider the following examples.
1546The numbers to the left are the rule that is being applied
1547to make the transformation.
1548.(b
1549.re
1550	esvax.asa
1551[1]	esvax:asa
1552[10]	$#berk$@esvax$:asa
1553.)b
1554.(b
1555	research^vax135^dmr
1556[5]	research!vax135^dmr
1557[5]	research!vax135!dmr
1558[7]	$#berk$@csvax$:research!vax135!dmr
1559.)b
1560.(b
1561	research!ucbvax!j:eric
1562[6]	csvax:j:eric
1563[8]	j:eric
1564[9]	eric
1565[11]	$#local$:eric
1566.)b
1567.(b
1568	ing70:wnj@Berkeley
1569[2]	wnj@Berkeley
1570[3]	ing70:wnj
1571[10]	$#berk$@ing70$:wnj
1572.)b
1573.sh 3 "Rewriting rules for sender addresses"
1574.(b
1575.sz -2
1576.ta \w'R\&CSVAX:$-h!$+u  'u +\w'$+u@$+h  'u
1577S\&1
1578R\&ing70:$+u@$-h	$+u@$+h	arpanet mail is automatic
1579R\&CSVAX:$-h!$+u	$+h!$+u	uucp mail is automatic
1580.sz
1581.)b
1582The
1583.b S
1584line starts putting the rules into set one.
1585These rules strip off the
1586.q ing70:
1587from incoming ARPANET mail
1588and the
1589.q CSVAX:
1590off of incoming UUCP mail.
1591.pp
1592The name classes could be used here,
1593but using literal strings is safe
1594because they will always be program-generated.
1595.sh 1 "COMPARISON WITH OTHER MAILERS"
1596.sh 2 "Delivermail"
1597.pp
1598.i Sendmail
1599is an outgrowth of
1600.i delivermail .
1601The primary differences are:
1602.np
1603Configuration information is not compiled in.
1604This simplifies many of the problems
1605of moving to other machines.
1606It also allows easy debugging of new mailers.
1607.np
1608Address parsing is more flexible.
1609For example,
1610.i delivermail
1611only supported one gateway to any network,
1612whereas
1613.i sendmail
1614can be sensitive to host names
1615and reroute to different gateways.
1616.np
1617Forwarding and
1618:include:
1619features eliminate the requirement that the system alias file
1620be writable by any user
1621(or that an update program be written,
1622or that the system administration make all changes).
1623.np
1624.i Sendmail
1625supports message batching across networks
1626when a message is being sent to multiple recipients.
1627.sh 2 "MMDF"
1628.pp
1629MMDF
1630[Crocker79]
1631spans a much wider problem set than
1632.i sendmail .
1633For example,
1634MMDF includes a
1635.q "phone network"
1636mailer, whereas
1637.i sendmail
1638calls on preexisting mailers in most cases.
1639.i Sendmail
1640is approximately equivalent to the
1641SUBMIT and DELIVER phases of MMDF.
1642Because of this difference in design goals,
1643some of the important features of MMDF
1644(queueing, retransmission, and two-phase timeout)
1645are unimplemented by
1646.i sendmail .
1647.pp
1648MMDF and
1649.i sendmail
1650both support aliasing,
1651customized mailers,
1652message batching,
1653and automatic forwarding to gateways.
1654.sh 2 "Message Processing Module"
1655.pp
1656The Message Processing Module (MPM)
1657discussed by Postel [Postel79b]
1658matches
1659.i sendmail
1660closely in terms of its basic architecture.
1661However,
1662like MMDF,
1663the MPM includes the network interface software
1664as part of its domain.
1665.pp
1666MPM also postulates a duplex channel to the receiver,
1667as does MMDF.
1668This allows simpler handling of errors
1669by the mailer
1670than possible in
1671.i sendmail ;
1672when a message queued by
1673.i sendmail
1674is sent,
1675any errors must be returned to the sender
1676by the mailer itself.
1677Both MPM and MMDF mailers
1678can return an immediate error response,
1679and a single error processor can create an appropriate response.
1680.pp
1681MPM prefers passing the message as a structured message,
1682with type-length-value tuples.
1683This implies a much higher degree of cooperation
1684between mailers than required by
1685.i sendmail .
1686MPM also assumes a universally agreed upon internet name space
1687(with each address a net-host-user tuple),
1688which
1689.i sendmail
1690does not.
1691.sh 1 "EVALUATIONS AND FUTURE PLANS"
1692.pp
1693.i Sendmail
1694is designed to work in a nonhomogeneous environment.
1695Every attempt is made to avoid imposing any constraints
1696on the underlying mailers.
1697This goal has driven much of the design.
1698One of the major problems
1699has been the lack of a uniform address space,
1700as postulated in [Postel79a]
1701and [Postel79b].
1702.pp
1703A nonuniform address space implies that path will be specified
1704in all addresses,
1705either explicitly (as part of the address)
1706or implicitly
1707(as with implied forwarding to gateways).
1708This has the unpleasant effect of making replying to messages
1709exceedingly difficult,
1710since there is no one
1711.q address
1712for any person,
1713but only a way to get there from wherever you are.
1714.pp
1715Interfacing to mail programs
1716that were not initially intended to be applied
1717in an internet environment
1718has been amazingly successful,
1719and has reduced the job to a manageable task.
1720.pp
1721However,
1722many of these mailers implement their own queueing and retransmission.
1723In networks that support store-and-forward file transfer,
1724such as BerkNet and UUCP,
1725this feature must be supplied already.
1726However,
1727networks that transfer in real time,
1728such as the ARPANET or an Ether-based network
1729[Ether99],
1730generally do not provide these features.
1731Also,
1732networks which provide these generally do not understand
1733timeouts or returning the text of the message on error,
1734both highly desirable features\**.
1735.(f
1736\**We have implemented an ARPANET mailer which
1737returns the message on error and does one-stage timeout
1738(returning the message after three days).
1739.)f
1740Such queueing, retransmission, and two-phase timeout
1741may be integrated into
1742.i sendmail
1743if it seems desirable.
1744.pp
1745.i Sendmail
1746has knowledge of a few difficult environments
1747built in.
1748It generates ARPANET FTP compatible error messages
1749(prepended with three-digit numbers
1750[Neigus78, FTP2])
1751as necessary,
1752optionally generates UNIX-style
1753.q From
1754lines on the front of messages for some mailers,
1755and knows how to parse the same lines on input.
1756This can be inconvenient to sites which have abandoned UNIX mail,
1757although
1758.i sendmail
1759still adds and understands ARPANET-style
1760.q From:
1761lines.
1762Also,
1763error handling has an option customized for BerkNet.
1764.pp
1765One surprisingly major annoyance in most internet mailers
1766(such as MMDF)
1767is that the location and format of local mail is built in\**.
1768.(f
1769\**For example,
1770MMDF puts local mail in the file
1771.q .mail
1772\*- useful if you are running version 6.
1773.)f
1774.i Sendmail
1775eliminates all knowledge of location
1776and can function successfully with different formats.
1777.pp
1778The ability to automatically generate a response to incoming mail
1779(by forwarding mail to a program)
1780seems useful
1781(\c
1782.q "I am on vacation until late August...." )
1783but can create problems
1784such as forwarding loops
1785(two people on vacation whose programs send notes back and forth,
1786for instance)
1787if these programs are not well written.
1788A program should be written to do standard tasks correctly,
1789but this does not solve the general case.
1790It might be desirable to implement some form of load limiting.
1791I am unaware of any mail system that addresses this problem,
1792nor am I aware of any reasonable solution at this time.
1793.pp
1794.i Sendmail
1795should be modified to run as a daemon,
1796reading an MPX file
1797(or other IPC scheme)
1798to receive mail and process it.
1799This would reduce the cost of sending mail to writing the message
1800into a known file.
1801.i Sendmail
1802would be modified to have a very different argument structure.
1803It already has an option to read the recipients
1804from the message header.
1805A more palatable technique for giving error messages
1806would also have to be devised.
1807.pp
1808The configuration file is currently practically inscrutable;
1809considerable convenience could be realized
1810with a higher-level format.
1811For example, a description might read:
1812.(b
1813.re
1814(MACRO name value)
1815(HEADER name value
1816	(OPTION option) ...
1817	(NEEDS option) ... )
1818(MAILER name path xlatstring
1819	(OPTION option) ...
1820	(ARGV arg ... ))
1821(CLASS name word ...)
1822(REWRITE setname
1823	(RULE lhs rhs) ... )
1824.)b
1825.pp
1826It seems clear that common protocols will be changing soon
1827to accommodate changing requirements and environments.
1828These changes will include modifications to the message header
1829[NBS80]
1830or to the body of the message itself
1831(such as for multimedia messages
1832[Postel80]).
1833Other changes will include changes to communication protocols
1834which may effect
1835.i sendmail ;
1836for example, the changes implied by the new Mail Transfer Protocol
1837[Sluizer81].
1838These changes should be relatively trivial to integrate
1839into the existing system.
1840.pp
1841Many other nice features could be implemented.
1842For example,
1843if we were sure that the alias file were writable by the effective user
1844(i.e., if
1845.i sendmail
1846were to run setuid)
1847then the inverted form could be rebuilt automatically when the
1848text copy was changed.
1849However, this appears to be little more than frosting.
1850must be properly balanced and nested.
1851.pp
1852Some proposals call for a single address syntax,
1853such that the host name uniquely determines the network.
1854There are a number of evident problems with this.
1855In a large internet,
1856the database update problem becomes considerable,
1857especially under multiple managements;
1858this can be solved by a daemon that updates the tables
1859dynamically,
1860but it is not clear what the problems are here.
1861More to the point,
1862this requires a unique namespace among all networks.
1863In our current configuration
1864we have been unable to even find out the names of all the hosts
1865on the UUCP network;
1866to hope that on an internet with fifty or more networks
1867would have no name conflicts is beyond the scope of
1868.i sendmail .
1869Despite the difficulties, however,
1870this is probably a better long-term solution to the problem
1871of internet addressing.
1872The ambiguities implied by addresses combining
1873left-associative and right-associative addresses
1874are impossible to solve without parentheses;
1875acceptable for mathematical equations,
1876but absurd for network addresses.
1877.pp
1878A related problem occurs with the user namespace.
1879In tightly coupled environments,
1880it would be nice to have automatic forwarding between machines
1881on the basis of the user name alone,
1882without cumbersome aliases.
1883This would require an automatically updated database
1884and some method of resolving conflicts.
1885Ideally this would be effective even with multiple managements.
1886A student at Berkeley,
1887Allan Biocca,
1888is working on a facility which may provide the necessary functionality.
1889.pp
1890In the long run,
1891a system that understands canonical internet addresses
1892(net, host, user)
1893implemented in a world that understands these addresses
1894would be an incredible win.
1895.i Sendmail
1896seems to be a useful tool to pull together
1897the haphazard environment that exists today,
1898until the better tools permeate the internetwork world.
1899.sh 0 "ACKNOWLEDGEMENTS"
1900.pp
1901Thanks are due to Kurt Schoens for his continual cheerful
1902assistance and good advice,
1903Bill Joy for pointing me in the correct direction
1904(over and over),
1905and Mark Horton for more advice,
1906prodding,
1907and many of the good ideas.
1908Kurt and Eric Schmidt are to be credited
1909for using
1910.i delivermail
1911as a server for their programs
1912(\c
1913.i Mail
1914and BerkNet respectively)
1915before any sane person should have,
1916and making the necessary modifications
1917promptly and happily.
1918Eric gave me considerable advice about the perils
1919of network software which saved me an unknown
1920amount of work and grief.
1921Mark did the original implementation of the DBM version
1922of aliasing, installed the VFORK code,
1923wrote the current version of
1924.i rmail ,
1925and was the person who really convinced me
1926to put the work into
1927.i delivermail
1928to turn it into
1929.i sendmail .
1930Kurt deserves accolades for using
1931.i sendmail
1932when I was myself afraid to take the risk;
1933how a person can continue to be so enthusiastic
1934in the face of so much bitter reality is beyond me.
1935.pp
1936Kurt, Bill, and Kirk McKusick
1937read early copies of this paper,
1938giving considerable useful advice.
1939.pp
1940Special thanks are reserved for Mike Stonebraker,
1941who knowingly allowed me to put so much work into this
1942when there were so many other things I really should
1943have been working on.
1944.+c
1945.ce
1946REFERENCES
1947.nr ii 1.5i
1948.ip [Crocker77a]
1949Crocker, D. H.,
1950Vittal, J. J.,
1951Pogran, K. T.,
1952and
1953Henderson, D. A. Jr.,
1954.ul
1955Standard for the Format of ARPA Network Text Messages.
1956RFC 733,
1957NIC 41952.
1958In [Feinler78].
1959November 1977.
1960.ip [Crocker77b]
1961Crocker, D. H.,
1962.ul
1963Framework and Functions of the MS Personal Message System.
1964R-2134-ARPA,
1965Rand Corporation,
1966Santa Monica, California.
19671977.
1968.ip [Crocker79]
1969Crocker, D. H.,
1970Szurkowski, E. S.,
1971and
1972Farber, D. J.,
1973.ul
1974An Internetwork Memo Distribution Facility \*- MMDF.
19756th Data Communication Symposium,
1976Asilomar.
1977November 1979.
1978.ip [Ether99]
1979Boggs, D.,
1980and who???
1981.ul
1982Ethernet....
1983.ip [Feinler78]
1984Feinler, E.,
1985and
1986Postel, J.
1987(eds.),
1988.ul
1989ARPANET Protocol Handbook.
1990NIC 7104,
1991Network Information Center,
1992SRI International,
1993Menlo Park, California.
19941978.
1995.ip [FTP2]
1996Revised FTP Reply Codes.
1997RFC xxxx.
1998In [Feinler78].
1999.ip [MH99]
2000MH.
2001.ip [NBS80]
2002National Bureau of Standards,
2003.ul
2004Specification of a Draft Message Format Standard.
2005Report No. ICST/CBOS 80-2.
2006October 1980.
2007.ip [Neigus78]
2008Neigus, N.,
2009.ul
2010File Transfer Protocol for the ARPA Network.
2011RFC xxxx.
2012In [Feinler78].
20131978.
2014.ip [Nowitz78a]
2015Nowitz, D. A.,
2016and
2017Lesk, M. E.,
2018.ul
2019A Dial-Up Network of UNIX Systems.
2020Bell Laboratories.
2021In
2022UNIX Programmer's Manual, Seventh Edition,
2023Volume 2.
2024August, 1978.
2025.ip [Nowitz78b]
2026Nowitz, D. A.,
2027.ul
2028Uucp Implementation Description.
2029Bell Laboratories.
2030In
2031UNIX Programmer's Manual, Seventh Edition,
2032Volume 2.
2033October, 1978.
2034.ip [Postel77]
2035Postel, J.,
2036.ul
2037Mail Protocol.
2038NIC 29588.
2039In [Feinler78].
2040November 1977.
2041.ip [Postel79a]
2042Postel, J.,
2043.ul
2044Internet Message Protocol.
2045RFC 753,
2046IEN 85.
2047Network Information Center,
2048SRI International,
2049Menlo Park, California.
2050March 1979.
2051.ip [Postel79b]
2052Postel, J. B.,
2053.ul
2054An Internetwork Message Structure.
2055IEN xxxx.
2056Network Information Center,
2057SRI International,
2058Menlo Park, California.
20591979.
2060.ip [Postel80]
2061Postel, J. B.,
2062.ul
2063A Structured Format for Transmission of Multi-Media Documents.
2064RFC 767.
2065Network Information Center,
2066SRI International,
2067Menlo Park, California.
2068August 1980.
2069.ip [Schmidt99]
2070Schmidt, E.,
2071.ul
2072The Berkeley Network.
2073University of California, Berkeley California.
20741999.
2075.ip [Schoens79]
2076Schoens, K.,
2077.ul
2078Mail Reference Manual.
2079University of California, Berkeley.
2080In UNIX Programmer's Manual,
2081Seventh Edition,
2082Volume 2C.
2083December 1979.
2084.ip [Sluizer81]
2085Sluizer, S.,
2086and
2087Postel, J. B.,
2088.ul
2089Mail Transfer Protocol.
2090RFC 780.
2091Network Information Center,
2092SRI International,
2093Menlo Park, California.
2094May 1981.
2095.ip [UNIX80]
2096.ul
2097The UNIX Programmer's Manual, Seventh Edition,
2098Virtual VAX-11 Version,
2099Volume 1.
2100Bell Laboratories,
2101modified by the University of California,
2102Berkeley California.
2103November 1980.
2104.++ A
2105.+c "SENDMAIL USAGE"
2106.pp
2107Arguments must be presented with flags before addresses.
2108The flags are:
2109.nr ii 1i
2110.ip "\-f addr"
2111The sender's machine address is
2112.i addr .
2113This flag is ignored unless the real user
2114is root,
2115network,
2116or uucp,
2117or if
2118.i addr
2119contains an exclamation point
2120(because of certain restrictions in UUCP).
2121.ip "\-r addr"
2122An obsolete form of
2123.b \-f .
2124.ip "\-h cnt"
2125Sets the
2126.q "hop count"
2127to
2128.i cnt .
2129This represents the number of times this message has been processed
2130by
2131.i sendmail
2132(to the extent that it is supported by the underlying networks).
2133.i Cnt
2134is incremented during processing,
2135and if it reaches
2136MAXHOP
2137(currently 30)
2138.i sendmail
2139throws away the message with an error.
2140.ip "\-F\&name"
2141Sets the full name of this user to
2142.i name .
2143.ip \-e\&p
2144Print error messages (default).
2145.ip \-e\&q
2146Throw away error messages.
2147The only response is the exit status.
2148.ip \-e\&m
2149Mail back errors.
2150.ip \-e\&w
2151.q Write
2152back errors \*- or mail them if the user is not logged in.
2153.ip \-e\&e
2154Do special error processing for BerkNet.
2155This involves mailing back the errors
2156but always returning a zero exit status.
2157.ip \-n
2158Don't do aliasing or forwarding.
2159.ip \-m
2160Include me in alias expansions.
2161Normally
2162.i sendmail
2163suppresses the sender
2164if in a group being sent to.
2165.ip \-i
2166Don't take a dot to end a message.
2167.ip \-t
2168Read the header for
2169.q To: ,
2170.q Cc: ,
2171and
2172.q Bcc:
2173lines, and send to everyone listed in those lists.
2174The
2175.q Bcc:
2176line will be deleted before sending.
2177Any addresses in the argument vector will be deleted
2178from the send list.
2179.ip \-a\&m
2180Do special processing for the
2181ARPANET.
2182This includes reading the
2183.q "From:"
2184line from the header to find the sender,
2185printing
2186ARPANET
2187style messages
2188(preceded by three digit reply codes for compatibility with
2189the FTP protocol
2190[Neigus78, FTP2, Postel77]),
2191and ending lines of error messages with <CRLF>.
2192.ip \-a\&f
2193Same as
2194.b \-a\&m ,
2195except print out message numbers appropriate for the MLFL command
2196[Postel77].
2197.ip \-s
2198Save UNIX-style
2199.q From
2200lines at the beginning of headers.
2201Normally they are assumed redundant
2202and discarded.
2203.ip \-v
2204Give a blow-by-blow description of function.
2205This gives information of interest to the user
2206rather than for the
2207.i sendmail
2208maintainer;
2209for example,
2210aliases are printed as expanded
2211and mailer functions are printed as they run.
2212.ip \-C\&file
2213Use a different configuration file.
2214.ip \-A\&file
2215Use a different alias file.
2216.ip \-I
2217Initialize the DBM version
2218of the alias file.
2219If
2220.b \-I
2221is given,
2222no delivery is attempted.
2223.ip \-V
2224Verify the addresses only.
2225Only partial verification is done:
2226syntax is checked, and local names are verified,
2227but no checking normally done by the mailer is attempted.
2228.ip \-d\&level
2229Set debugging level.
2230.ip \-D\&x\&val
2231Define macro
2232.i x
2233to have value
2234.i val .
2235.nr ii 5n
2236.+c "OTHER CONFIGURATION"
2237.pp
2238There are some configuration changes that can be made by
2239recompiling
2240.i sendmail .
2241Some of these are changes to compilation flags:
2242.nr ii 1i
2243.ip V6
2244If set,
2245this will compile a version 6 system,
2246with 8-bit user id's,
2247single character tty id's,
2248etc.
2249If not set,
2250a version 7 system is assumed.
2251.ip DBM
2252If set,
2253the
2254.q DBM
2255package in UNIX is used
2256(see DBM(3X) in [UNIX80]).
2257If not set,
2258a much less efficient algorithm for processing aliases is used.
2259.ip VFORK
2260Set if your system has the experimental
2261.i vfork
2262system call.
2263See vfork(2) in [UNIX80].
2264If not set,
2265the regular
2266.i fork
2267system call is used.
2268This option improves performance.
2269.ip DEBUG
2270If set, debugging information is compiled in.
2271To actually get the debugging output,
2272the
2273.b \-d
2274flag must be used.
2275.ip LOG
2276If set,
2277the
2278.i syslog
2279routine in use at some Berkeley sites is used.
2280This logs an informational log record
2281for each message processed,
2282and logs a higher priority log record
2283for internal system errors.
2284.ip NEWFTP
2285If set, the ARPANET reply codes for
2286.q "Revised New FTP"
2287are used
2288[FTP2].
2289If not set,
2290reply codes for the old, unrevised
2291.q "New FTP"
2292are used
2293[Neigus78].
2294If you want to use reply codes for the Mail Transfer Protocol
2295[Sluizer81]
2296you may find it necessary to make some code modifications.
2297.ip PARANOID
2298There are places where
2299.i sendmail
2300may opt for a more secure,
2301but probably less convenient environment.
2302For example,
2303if this flag is set
2304it is not possible to specify a program as an address directly;
2305this can only be done with an alias.
2306.nr ii 5n
2307.pp
2308If you want to enable special processing of other headers,
2309you will have to add them to the
2310.i HdrInfo
2311table in
2312.i conf.c .
2313This table contains the header name
2314(which should be in all lower case),
2315a set of header control flags (described below),
2316and a set of mailer flags,
2317used by some of the header flags.
2318The header flags are:
2319.nr ii \w'H_ACHECK  'u
2320.ip H_CHECK
2321Check the flags for the receiving mailer
2322against the third field in the
2323.i HdrInfo
2324entry.
2325If the mailer has any of those bits set,
2326send this field;
2327otherwise, do not send this field to that mailer.
2328If the field was in the message originally, however,
2329it will always be sent
2330(i.e., this only applies to headers being added by
2331.i sendmail ).
2332.ip H_ACHECK
2333Same as H_CHECK,
2334except that it even applies to headers that were in the
2335original message.
2336That is,
2337if this bit is set and the mailer does not have flag bits set
2338that intersect with the third field in this
2339.i HdrInfo
2340entry,
2341the header line is
2342.i always
2343deleted.
2344.ip H_EOH
2345If this header field is set,
2346treat it like a blank line,
2347i.e.,
2348it will signal the end of the header
2349and the beginning of the message text.
2350.ip H_FORCE
2351Add this header entry
2352even if one existed in the message before.
2353If a header entry does not have this bit set,
2354.i sendmail
2355will not add another header line if a header line
2356of this name already existed.
2357This would normally be used to stamp the message
2358by everyone who handled it.
2359.ip H_ADDR
2360If set,
2361this field contains recipient addresses.
2362This is used by the
2363.b \-t
2364flag to determine who to send to
2365when it is collecting recipients from the message.
2366.nr ii 5n
2367.lp
2368Let's look at a sample
2369.i HdrInfo
2370specification:
2371.(b
2372.sz -2
2373.ta 4n +\w'"received-from",  'u +\w'H_ADDR|H_ACHECK,  'u
2374struct hdrinfo	HdrInfo[] =
2375{
2376	"date",	H_CHECK,	M_NEEDDATE,
2377	"from",	H_CHECK,	M_NEEDFROM,
2378	"original-from",	H_ACHECK,	0,
2379	"sender",	0,	0,
2380	"full-name",	H_ACHECK,	M_FULLNAME,
2381	"to",	H_ADDR,	0,
2382	"cc",	H_ADDR,	0,
2383	"bcc",	H_ADDR|H_ACHECK,	0,
2384	"message-id",	H_CHECK,	M_MSGID,
2385	"message",	H_EOH,	0,
2386	"text",	H_EOH,	0,
2387	"received-date",	H_CHECK,	M_LOCAL,
2388	"received-from",	H_CHECK,	M_LOCAL,
2389	"via",	H_FORCE,	0,
2390	NULL,	0,	0,
2391};
2392.sz
2393.)b
2394This specification says that the
2395.q Date: ,
2396.q From: ,
2397.q Message-Id: ,
2398.q Received-Date: ,
2399and
2400.q Received-From:
2401must be requested by the mailer to be inserted.
2402However,
2403if they were in the message as received by
2404.i sendmail
2405they will be propagated.
2406The
2407.q Full-Name:
2408field, on the other hand,
2409will be deleted even if it was specified before,
2410unless the mailer wants it.
2411The
2412.q Original-From:
2413and
2414.q Bcc:
2415fields will be deleted unconditionally
2416(since it is never possible for a mailer's flags
2417to intersect with zero).
2418The
2419.q Original-From:
2420is in fact used internally,
2421and will be reinserted by ad hoc code,
2422but only if it differs from the
2423.q From:
2424line that would otherwise be inserted.
2425.q To: ,
2426.q Cc: ,
2427and
2428.q Bcc:
2429all specify recipient addresses.
2430The
2431.q Message:
2432and
2433.q Text:
2434fields will terminate the header;
2435these are specified in new protocols
2436[NBS80]
2437or used by random dissenters around the network world.
2438The
2439.q Via:
2440field will always be added,
2441and can be used to trace messages.
2442The
2443.q Sender:
2444field is used internally,
2445although no cliched special processing occurs.
2446.pp
2447There are a number of important points here.
2448First,
2449header fields are not added automatically just because they are in the
2450.i HdrInfo
2451structure;
2452they must be specified in the configuration file
2453in order to be added to the message.
2454Any header fields mentioned in the configuration file but not
2455mentioned in the
2456.i HdrInfo
2457structure have default processing performed;
2458that is,
2459they are added unless they were in the message already.
2460Second,
2461the
2462.i HdrInfo
2463structure only specifies cliched processing;
2464certain headers are processed specially by ad hoc code
2465regardless of the status specified in
2466.i HdrInfo .
2467For example,
2468the
2469.q Sender:
2470and
2471.q From:
2472fields are always scanned on ARPANET mail
2473to determine the sender;
2474this is used to perform the
2475.q "return to sender"
2476function.
2477The
2478.q "From:"
2479and
2480.q "Full-Name:"
2481fields are used to determine the full name of the sender
2482if possible;
2483this is stored in the macro
2484.b $x
2485and used in a number of ways.
2486Although the
2487.q "Original-From:"
2488field is specified to be deleted in
2489.i HdrInfo ,
2490it is added automatically if the
2491.q From:
2492field that would be generated internally
2493differs from the
2494.q From:
2495field that was specified in the message;
2496in this case,
2497the original
2498.q From:
2499field is renamed
2500.q Original-From: .
2501.pp
2502The file
2503.i conf.c
2504also contains the specification of ARPANET reply codes.
2505There are six classifications these fall into:
2506.(b
2507.sz -2
2508.ta \w'char  'u +\w'Arpa_Usrerr[] =  'u +\w'"999";  'u
2509char	Arpa_Info[] =	"050";	/* arbitrary info */
2510char	Arpa_Enter[] =	"350";	/* start mail input */
2511char	Arpa_Mmsg[] =	"256";	/* mail successful (MAIL cmd) */
2512char	Arpa_Fmsg[] =	"250";	/* mail successful (MLFL cmd) */
2513char	Arpa_Syserr[] =	"455";	/* some (transient) system error */
2514char	Arpa_Usrerr[] =	"450";	/* some (fatal) user error */
2515.sz
2516.)b
2517The class
2518.i Arpa_Info
2519is for any information that is not required by the protocol,
2520such as forwarding information.
2521.i Arpa_Enter
2522is output when
2523.i sendmail
2524wants to start receiving the mail.
2525.i Arpa_Mmsg
2526and
2527.i Arpa_Fmsg
2528are given if the mail is successfully delivered;
2529the selection of message number depends on the FTP command given
2530(which is communicated via the
2531.b \-a
2532flag).
2533.i Arpa_Syserr
2534is printed by the
2535.i syserr
2536routine;
2537typically, this occurs when something has gone wrong at the
2538receiving site,
2539with the assumption that it is a transient condition.
2540Finally,
2541.i Arpa_Usrerr
2542is the result of a user error
2543and is generated by the
2544.i usrerr
2545routine;
2546these are generated when the user has specified something wrong,
2547and hence the error is permanent,
2548i.e.,
2549it will not work simply by resubmitting the request.
2550.pp
2551If it is necessary to restrict mail through a gateway,
2552the
2553.i checkcompat
2554routine can be modified.
2555This routine is called for every recipient address.
2556It can return
2557.b TRUE
2558to indicate that the address is acceptable
2559and mail processing will continue,
2560or it can return
2561.b FALSE
2562to reject the recipient.
2563If it returns false,
2564it is up to
2565.i checkcompat
2566to print an error message
2567(using
2568.i usrerr )
2569saying why the message is rejected.
2570For example,
2571.i checkcompat
2572could read:
2573.(b
2574.re
2575.sz -2
2576bool
2577checkcompat(to)
2578	register ADDRESS *to;
2579{
2580	if (MsgSize > 50000 && to->q_mailer != MN_LOCAL)
2581	{
2582		usrerr("Message too large for non-local delivery");
2583		return (FALSE);
2584	}
2585	return (TRUE);
2586}
2587.sz
2588.)b
2589This would reject messages greater than 50000 bytes
2590unless they were local.
2591The actual use of this routine is highly dependent on the
2592implementation,
2593and use should be limited.
2594