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