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