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