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