1.nr DR 1	\" this is a draft copy
2.nr si 3n
3.he 'SENDMAIL''%'
4.if \n(DR .fo '\*-DRAFT\*-'\*(td'\*-DRAFT\*-'
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.18,
25last modified on 05/15/82.
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.
130However, it is not unreasonable to expect
131escrow to take several years to close on this
132new world.
133.sp
134.pp
135Section 1 discusses the design goals for
136.i sendmail .
137Section 2 gives an overview of the basic functions of the system.
138In section 3,
139details of usage are discussed.
140A detailed description of the configuration file
141is given in section 4,
142including a walkthrough of a specific configuration file.
143Section 5 compares
144.i sendmail
145to other internet mail routers,
146and an evaluation of
147.i sendmail
148is given in section 6,
149including future plans.
150.sh 1 "DESIGN GOALS"
151.pp
152.i Sendmail
153is an outgrowth of
154.i delivermail,
155a previous incarnation of a UNIX internetwork mail router.
156.i Delivermail
157was written relatively quickly.
158The first version could only parse addresses based on single
159characters embedded in the address,
160required explicit
161description of gateways,
162and had only limited aliasing;
163automatic forwarding of messages to another gateway and other features
164came later.
165.pp
166Design goals for
167.i delivermail
168included:
169.np
170Compatibility with the existing mail system,
171including Bell version 6 mail,
172Bell version 7 mail
173[UNIX80],
174Berkeley
175.i Mail
176[Shoens79],
177BerkNet mail
178[Schmidt79],
179and hopefully UUCP mail
180[Nowitz78a, Nowitz78b].
181ARPANET mail
182[Crocker77a, Postel77]
183was also required.
184.np
185Reliability, in the sense of guaranteeing
186that every message is correctly delivered
187or at least brought to the attention of a human
188for correct disposal;
189no message should ever be completely lost.
190This was considered essential
191because of the emphasis on mail in our environment.
192This turned out to be one of the hardest goals to satisfy,
193especially in the face of the many anomalous message formats
194produced by various ARPANET sites.
195For example,
196certain sites generate incorrect from addresses
197which caused error message loops.
198Some hosts use blanks in names,
199which created problems with
200UNIX mail programs that assume that an address
201is one word.
202And at least one person lists his address as
203.q "From: the TTY of ..." ,
204giving a
205.q Sender:
206field with his real address.
207In summary,
208the obscure aspects of the ARPANET mail protocol
209really
210.i are
211used and
212are difficult to support,
213but must be supported.
214But even obeying the standard is insufficient.
215For example,
216WHARTON changes our host name from
217.q BERKELEY
218to
219.q BERKEL- ,
220which confused error processing.
221Degenerate cases such as this
222must be handled gracefully.
223.pp
224There were certain other non-goals in
225.i delivermail .
226These resulted from the expectation that
227it would only be used at Berkeley,
228and probably only at a few sites at Berkeley.
229.np
230It was fair game to compile configuration information
231into the code,
232even to assume that every host was running BerkNet.
233.np
234The problem of multiple gateways to a single network
235was not foreseen.
236For example,
237all UUCP mail was sent to a single gateway host.
238In fact,
239Berkeley has at least three UUCP gateway hosts.
240.np
241No attempt was made to reduce the volume of mail across a network link
242by sending only one copy of a message
243to multiple recipients on the same host.
244Besides the difficulty of doing this,
245we failed to appreciate how much volume there would be.
246For example,
247one of our gateways processed a message approximately
248every twenty seconds
249during peak hours, many of which were duplicates.
250.np
251Existing software to do actual delivery
252should be used whenever possible.
253This resulted as much from political and practical considerations
254as technical.
255.pp
256This resulted in an architecture illustrated in figure 1.
257.(z
258.hl
259.ie t \
260.	sp 18
261.el \{\
262.(c
263+---------+   +---------+   +---------+
264| sender1 |   | sender2 |   | sender3 |
265+---------+   +---------+   +---------+
266     |  	   |             |
267     +----------+  +  +----------+
268		|  |  |
269		v  v  v
270            +-------------+
271            | delivermail |
272            +-------------+
273		|  |  |
274     +----------+  +  +----------+
275     |  	   |             |
276     v             v             v
277+---------+   +---------+   +---------+
278| mailer1 |   | mailer2 |   | mailer3 |
279+---------+   +---------+   +---------+
280.)c
281.\}
282
283.ce
284Figure 1 \*- Delivermail System Structure.
285.hl
286.)z
287The user interacts with a mail generating and sending program.
288When the mail is created,
289the generator calls
290.i delivermail ,
291which routes the message to the correct mailer(s).
292Since some of the senders may be network servers
293and some of the mailers may be network users,
294.i delivermail
295may be used as an internet mail gateway.
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 begins with a slash mark (\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
803.i Sendmail
804defines a set of standard exit status codes
805that should be returned by mailers.
806These are in turn returned by
807.i sendmail .
808.sh 2 "Queued Messages"
809.pp
810If the mailer gave a
811.q "temporary failure"
812exit status,
813the message is queued.
814A control file is used to describe the recipients to be sent to
815and various other parameters.
816.sh 2 "Interaction With Other Mailers"
817.pp
818Two examples of how network-specific work is passed to other programs
819are the incoming UUCP mailer
820(\c
821.i rmail )
822and the outgoing ARPANET mailer.
823.sh 3 "Incoming UUCP mail"
824.pp
825Mail coming in from the UUCP network
826is not guaranteed to have a normal header line,
827nor will an argument be passed telling who it is from\**.
828.(f
829\**As a result of this,
830it is impossible to verify UUCP sender addresses.
831.)f
832Fortuitously,
833UUCP mail calls the program
834.i rmail
835rather than
836.i mail
837or
838.i sendmail .
839The
840.i rmail
841program has been modified here to do the special-purpose parsing
842necessary to decode UUCP headers
843and turn them into a normal UUCP address;
844this address is then passed to
845.i sendmail .
846.sh 3 "Outgoing ARPANET mail"
847.pp
848The ARPANET imposes many standards that
849.i sendmail
850does not care to enforce.
851For example,
852an arpanet sitename must be on
853.i every
854address,
855not just the
856.q "From:"
857address.
858Certain UNIX sites like to use
859.q %
860as an alternative to
861.q @ ,
862which must be translated.
863The outgoing ARPANET mailer makes these transformations
864before passing the message to the network.
865.sh 1 CONFIGURATION
866.pp
867Configuration is controlled primarily by the file
868.i /usr/lib/sendmail.cf .
869.i Sendmail
870should not need to be recomplied except
871.np
872To change operating systems
873(V6, V7/32V, 4BSD).
874.np
875To remove or insert the DBM
876(UNIX database)
877library.
878.np
879To change ARPANET reply codes.
880.np
881To add headers requiring special processing.
882.lp
883Adding mailers or changing parsing
884(i.e., rewriting)
885or routing information
886does not require recompilation.
887.pp
888If the mail is being sent by a local user,
889and the file
890.q .mailcf
891exists in the sender's home directory,
892that file is read as a configuration file
893after the system configuration file.
894The primary use of this is to add header lines.
895This could also be used to adjust the full name by
896defining the
897.b x
898macro; e.g.,
899.(b
900DxEric Allman in Outer Space
901.)b
902.sh 2 "Configuration File Description"
903.pp
904The configuration file is formatted
905as a series of text lines,
906each beginning with a character describing its semantics.
907Blank lines and lines beginning with a sharp sign
908(#)
909are ignored.
910Other lines are:
911.(b
912.ta 3n
913D	define macro
914H	define header
915M	define mailer
916S	use rewriting set
917C	define word class
918F	define word class from file
919R	specify rewriting rule
920.)b
921.pp
922See figure 2 for an example configuration file.
923Please note that this is intended as an example only.
924.(z
925.hl
926.sz -2
927.re
928##### sendmail configuration file
929.sp \n(psu
930### local hosts on various nets
931DABerkeley
932DBIngVAX
933DUucbvax
934.sp \n(psu
935### special macros
936# my name
937D\&n\&MAILER-DAEMON
938# UNIX header format
939D\&l\&From $g  $d
940# delimiter (operator) characters
941D\&o\&.:@!^
942# address writing style
943D\&q\&$g$?x ($x)$.
944.sp \n(psu
945### format of headers:
946H\&Date: $a
947H\&From: $g$?x ($x)$.
948H\&Full-Name: $x
949H\&Message-Id: <$t.$p.$B@$A>
950H\&Posted-Date: $a
951.sp \n(psu
952### name classifications
953# arpanet hostnames
954C\&A\&ucb berkeley
955# list of local host names
956C\&B\&j IngVax
957# berknet hosts on the arpanet
958C\&C\&i ingres ing70
959# uucp hostnames
960C\&U\&ucbvax ernie
961.sp \n(psu
962.ta \w'M\&local  'u +\w'/usr/net/bin/sendberkmail  'u +\w'rlsAmn  'u +\w'$f@$A  'u
963###  mailers
964M\&local	/bin/mail	rlsAmn	$f	...local\&mail -d $u
965M\&prog	/bin/csh	lA	$f	...prog\&mail -fc $u
966M\&berk	/usr/net/bin/sendberkmail	fxs	$B:$f	...berk\&mail -m $h -h $c -t $u
967M\&arpa	/usr/lib/mailers/arpa	sAu	$f@$A	...arpa\&mail $f $h $u
968M\&uucp	/usr/bin/uux	rsDxmU	$U!$f	...uucp\&mail - $h!rmail ($u)
969M\&xlate	/	A	$f	/
970.sp \n(psu
971### rewriting rules
972.ta \w'R\&CSVAX:$-h!$+u  'u +\w'$#berk$@ing70$:$+u@$+h  'u
973R\&$-.$+	$1:$2	change "." to ":"
974R\&$=C:$+@$-	$2@$3	delete ing70: on arpanet addresses
975R\&$+@$=A	ing70:$1	delete local arpa hosts
976R\&$+@$-	$#berk$@ing70$:$1@$2	send arpa mail to ing70
977R\&$+^$+	$1!$2	change "^" to "!"
978R\&$-!$=U!$+	csvax:$3	delete uucp loops through csvax
979R\&$-!$+	csvax:$1!$2	send uucp mail to csvax
980R\&$-:$-:$+	$2:$3	delete multiple berk hosts
981R\&$=B:$+	$2	delete local berk hosts
982R\&$-:$+	$#berk$@$1$:$2	resolve berk mail
983R\&$+	$#local$:$1	resolve local mail
984.sp \n(psu
985### rewriting rules for from host
986S\&1
987R\&ing70:$+@$-	$1@$2	arpanet mail is automatic
988R\&CSVAX:$-!$+	$1!$2	uucp mail is automatic
989.sp \n(psu
990### rewriting rules for translated sender
991S\&2
992R\&$-x:$-:$+	$2:$3	delete multiple berknet hosts
993.sz
994.sp
995.ce
996Figure 2.  Sample configuration file.
997.hl
998.)z
999.sh 3 "D \*- define macro"
1000.(b
1001.b D \c
1002.i x\|val
1003.)b
1004.pp
1005This line defines a macro
1006with the single character name
1007.i x
1008and value
1009.i val .
1010Macros can be interpolated using the escape
1011.b $ \c
1012.i x ,
1013where
1014.i x
1015is the macro name.
1016By convention,
1017all upper-case letters are unused by
1018.i sendmail
1019and may be used freely by the user;
1020all other names are reserved for use by sendmail.
1021Certain macros
1022.i must
1023be defined,
1024and are used internally.
1025These are:
1026.(b
1027.ta 4n
1028$l	UNIX-style \*(lqFrom\*(rq line.
1029$n	My address in error messages.
1030$o	\*(lqOperators\*(rq in addresses.
1031$q	How to write addresses in headers.
1032.)b
1033The
1034.b $l
1035macro is expanded when
1036.i sendmail
1037wants to insert a UNIX-style
1038.q From
1039line on messages.
1040This typically expands to something like:
1041.(b
1042From sally  Wed Aug 12 09:15:13 1981
1043.)b
1044The
1045.b $n
1046macro is used as the name of this process
1047when error messages are being mailed back.
1048Typically,
1049it is wise to include an alias
1050so that mail to this address will be sent to root.
1051The
1052.b $o
1053macro defines the characters
1054that will separate words when addresses are being broken up.
1055Each of these becomes a word by itself when scanned.
1056Blanks and tabs are built-in separators
1057but are ignored,
1058i.e., are not turned into words.
1059For example, the input:
1060.(b
1061Ing70:  ZRM  @  MIT-MC  SRI-KL
1062.)b
1063Is broken up into the six words:
1064.(b
1065Ing70, :, ZRM, @, MIT-MC, SRI-KL
1066.)b
1067assuming that colon and at-sign are operators
1068(but hyphen is not).
1069The
1070.b $q
1071macro gives the format for addresses
1072as they should appear in headers.
1073This will normally be something like:
1074.(b
1075$g$?x ($x)$.
1076.)b
1077Which will give the translated from address
1078followed by the full name if known.
1079.pp
1080A number of macros are defined by
1081.i sendmail
1082for use as primitives.
1083These are:
1084.(l
1085.ta 5n
1086$a	The \*(lqDate:\*(rq line date in ARPANET format.
1087$b	The current date in ARPANET format.
1088$c	The hop count.
1089$d	The date in UNIX (ctime) format.
1090$f	The sender's (from) address.
1091$g	The sender's address translated by the mailer.
1092$h	The host of the recipient.
1093$p	The process id of sendmail in decimal.
1094$t	The time in seconds in decimal.
1095$u	The user part of the recipient.
1096$v	The version number of sendmail.
1097$x	The full name of the sender.
1098$y	The id of the sender's terminal.
1099$z	The home directory of the recipient.
1100.)l
1101.pp
1102There are three types of dates that can be used.
1103The
1104.b $a
1105and
1106.b $b
1107macros are in ARPANET format;
1108.b $a
1109is a copy of the time extracted from the
1110.q Date:
1111field of the incoming message
1112(if there was one),
1113and
1114.b $b
1115is the current date and time \*- used for postmarks.
1116If no
1117.q Date:
1118is found in the message,
1119they are the same.
1120The
1121.b $d
1122macro has the date in UNIX
1123.i ctime
1124format;
1125this is extracted from the message if possible
1126and is otherwise the current date.
1127.pp
1128The
1129.b $f
1130macro is the id of the sender
1131as originally determined;
1132when mailing to a specific person,
1133the
1134.b $g
1135macro is the address of the sender
1136with respect to the receiver.
1137For example,
1138if I send to
1139.q csvax:samwise
1140the
1141.b $f
1142and
1143.b $g
1144macros are:
1145.(b
1146.ta 4n
1147$f	eric
1148$g	IngVAX:eric
1149.)b
1150This only applies to the first step in the link.
1151For example,
1152sending to Ing70:drb@bbn-unix,
1153we have
1154.b $f
1155and
1156.b $g
1157as above for the transfer to Ing70, but:
1158.(b
1159$f	IngVAX:eric
1160$g	IngVAX:eric@Berkeley
1161.)b
1162for transfer to the ARPANET\**.
1163.(f
1164\**When this is actually sent to the ARPANET,
1165this will appear as
1166IngVAX.eric@Berkeley.
1167The translation of the colon to a period is performed
1168by the mailer that queues ARPANET mail.
1169.)f
1170.pp
1171The
1172.b $x
1173macro is set to the full name of the sender.
1174This can be determined in several ways.
1175It can be passed as a flag to
1176.i sendmail .
1177The
1178.q Full-Name:
1179line in the header is the second option,
1180and the comment portion of the
1181.q From:
1182line is the third.
1183If all of these fail,
1184and if the message is being originated locally,
1185the full name is looked up in the
1186.i passwd
1187file.
1188.pp
1189When sending, the
1190.b $u ,
1191.b $h ,
1192and
1193.b $z
1194macros get set to the user, host, and home directory
1195(respectively)
1196of the receiver.
1197The host is only set if the user is not local,
1198and the home directory is only set if the user is local.
1199.pp
1200The
1201.b $p
1202and
1203.b $t
1204macros are used to create unique strings.
1205The
1206.b $y
1207macro is set to the id of the terminal of the sender
1208(if known);
1209some systems like to put this in the
1210.q From
1211line.
1212The
1213.b $v
1214macro is set to the version number of
1215.i sendmail ,
1216and can be used in postmarks
1217to help debugging.
1218.pp
1219A primitive conditional is available during macro expansion.
1220The construct:
1221.(b
1222$?x text1 $: text2 $.
1223.)b
1224tests if macro
1225.b $ \c
1226.i x
1227is defined.
1228If it is,
1229text1 is interpolated;
1230otherwise,
1231text2 is interpolated.
1232.sh 3 "H \*- define header"
1233.(b
1234.b H \c
1235.i "Field-Name" \c
1236.b ":" " \c
1237.i "field value"
1238.)b
1239.pp
1240The
1241.b H
1242line looks like a regular header line,
1243except that the field value is macro expanded
1244before use.
1245All headers mentioned in this way
1246are automatically inserted
1247into every message
1248except for headers mentioned in the compile-time
1249configuration file
1250.i conf.c .
1251These headers are
1252Date,
1253From,
1254Full-Name,
1255Message-Id,
1256and
1257Received-Date.
1258To get these fields the appropriate flag
1259must be specified
1260for the receiving mailer.
1261.pp
1262Since the file
1263.q ".mailcf"
1264in the sender's home directory is read and processed,
1265it is possible to add customized header lines.
1266For example,
1267the .mailcf consisting of:
1268.(b
1269H\&Phone: (415) 888-7770
1270.)b
1271will add that line to every outgoing message.
1272.sh 3 "M \*- define mailer"
1273.(b F
1274.b M \c
1275.i mailer-name
1276.i pathname
1277.i flags
1278.i from-macro
1279.i "argument list"
1280.)b
1281.pp
1282This line is structured into fields
1283separated by white space (spaces or tabs).
1284The fields are:
1285.np
1286The internal name of the mailer,
1287referred to in the rewriting rules.
1288.np
1289The pathname of the program to execute for this mailer.
1290.np
1291The flags for this mailer,
1292described below.
1293.np
1294The macro string to become the
1295.b $g
1296macro (translated sender)
1297for this mailer.
1298.np
1299The argument vector passed to the mailer
1300(macro expanded).
1301.pp
1302The flags are a series of characters:
1303.ls 1
1304.ip f
1305The mailer wants a
1306.b \-f
1307.i from
1308flag,
1309but only if this is a network forward operation
1310(i.e.,
1311the mailer will give an error
1312if the executing user does not have special permissions).
1313.ip r
1314Same as
1315.b f ,
1316but sends a
1317.b \-r
1318flag.
1319.ip q
1320Don't print errors \*- the mailer will do it for us.
1321.ip S
1322Don't reset your userid before calling the mailer.
1323This would be used in a secure environment where
1324.i sendmail
1325ran as a special user.
1326This could be used to prevent
1327(or at least complicate)
1328forged addresses.
1329This option is suppressed in
1330.q unsafe
1331configuration files
1332(i.e., user-supplied, either on a
1333command line
1334option, or in the
1335.i \&.mailcf
1336file in the home directory).
1337.ip n
1338This mailer does not want a UNIX-style
1339.q From
1340line on the message.
1341.ip l
1342This mailer is local,
1343so no host will be specified.
1344Also,
1345the mailer wants special local processing
1346(such as a
1347.q Received-Date:
1348field).
1349.ip s
1350Strip quote characters off of addresses
1351before calling the mailer.
1352.ip m
1353This mailer can send to multiple users
1354(on the same host)
1355in one call.
1356.ip F
1357This mailer wants a
1358.q From:
1359header line.
1360.ip D
1361This mailer wants a
1362.q Date:
1363header line.
1364.ip M
1365This mailer wants a
1366.q Message-Id:
1367header line.
1368.ip x
1369This mailer wants a
1370.q Full-Name:
1371header line.
1372.ip u
1373Upper case should be preserved in user names.
1374.ip h
1375Upper case should be preserved in host names.
1376.ip e
1377This mailer is expensive,
1378and it may be desirable to limit usage.
1379.ip R
1380The recipient addresses should be rewritten to be relative to the
1381receiver, rather than relative to the sender.
1382This is always done with sender addresses,
1383but should only be done on recipients
1384if the host you are sending to knows that it is being done.
1385Setting this flag makes it easy to do a
1386.q reply
1387command in a user mail program
1388(since all that must be done is send to all addresses in the message header),
1389but user mail programs that try to rewrite the addresses
1390will be completely confused.
1391.ip A
1392This mailer wants an ARPANET standard header
1393(equivalent to the
1394.b F
1395and
1396.b D
1397flags).
1398.ip U
1399This mailer is a UUCP mailer that wants leading from lines
1400of the form:
1401.(b
1402From sender <date> remote from sysname
1403.)b
1404instead of the more reasonable:
1405.(b
1406From sysname!sender <date>
1407.)b
1408A compilation flag must be on to include this code.
1409.ls
1410.lp
1411There should always be at least one flag,
1412since every message should include either a
1413.b x
1414or a
1415.b F
1416flag.
1417.sh 3 "S \*- use rewriting set"
1418.(b
1419.b S \c
1420.i N
1421.)b
1422.pp
1423There are three sets of rewriting rules.
1424Set zero is used to rewrite recipient addresses.
1425Set one is used to rewrite sender addresses.
1426Set two is applied after evaluating the
1427.q $g
1428macro,
1429i.e., after determining the from address for a particular mailer.
1430.pp
1431Set one can be used to eliminate implicit links.
1432For example,
1433if there exists a site on on the BerkNet called
1434.q Ing70
1435which is an ARPANET gateway,
1436and we are on a site called
1437.q IngVAX ,
1438ARPANET mail coming into
1439.q Ing70
1440for someone on
1441.q IngVAX
1442will read:
1443.(b
1444From: Ing70:auser@ahost
1445.)b
1446Rewriting set one can rewrite this as:
1447.(b
1448From: auser@ahost
1449.)b
1450since
1451.q Ing70
1452will be implied.
1453.pp
1454Set two is used to eliminate anomalies resulting from
1455forwarding.
1456For example,
1457a message received at Ing70 from mckusick on the CSVAX will
1458appear as:
1459.(b
1460From CSVAX:mckusick
1461.)b
1462If this is then forwarded to IngVAX,
1463sendmail on Ing70 will rewrite the from address as:
1464.(b
1465From Ing70:CSVAX:mckusick
1466.)b
1467The extra host reference can be eliminated by ruleset two on Ing70.
1468.pp
1469When you change to a new set,
1470the previous content of that set is cleared.
1471.sh 3 "R \*- rewriting rule"
1472.(b F
1473.b R \c
1474.i pattern
1475.i replacement
1476.i comments
1477.)b
1478.pp
1479The rewriting rules drive the address parser.
1480The rewriting process is essentially textual.
1481First,
1482the address to be rewritten is broken up into words.
1483Words are defined as strings of non-special characters
1484separated by white space or single special characters
1485as defined by the
1486.b $o
1487macro.
1488Then,
1489the words are rewritten using simple pattern matching.
1490Words in the pattern match themselves
1491unless they begin with dollar sign.
1492The dollar escapes have the following meanings\**:
1493.(f
1494\**These dollar escapes have nothing to do with macro expansion.
1495.)f
1496.(b
1497.ta 6n
1498$-	Match a single word.
1499$+	Match one or more words.
1500$=c	Match any word in class c (see below).
1501.)b
1502The case of letters is ignored in pattern matching
1503(including class comparisons).
1504.pp
1505When a pattern (also called a left hand side or LHS)
1506matches,
1507the input is rewritten as defined by the right hand side (RHS).
1508Acceptable escapes in the RHS are:
1509.(b
1510.ta \w'$#mailer  'u
1511$n	Replace from corresponding match in LHS.
1512$#mailer	Canonical mailer name.
1513$@host	Canonical host name.
1514$:user	Canonical user name.
1515.)b
1516The substitution from LHS to RHS is done by the index
1517of indefinite matches on the LHS.
1518Each pattern reexecutes until it fails.
1519As soon as the input resolves to a canonical name
1520(i.e.,
1521.q "$#mailer$@host$:user" ),
1522rewriting ends;
1523otherwise,
1524the next pattern is tried.
1525The
1526.q "$@host"
1527part is not needed
1528if the mailer does not require a host.
1529The special mailer
1530.q error
1531causes the user part to be printed as an error.
1532.sh 3 "C \*- define word class"
1533.(b F
1534.b C \c
1535.i c\|word\&1
1536.i word\&2 ...
1537.)b
1538.pp
1539There are twenty six word classes,
1540represented as
1541.q A
1542through
1543.q Z .
1544For example:
1545.(b
1546CVcsvax ingvax esvax
1547.)b
1548defines the words
1549.q csvax ,
1550.q ingvax ,
1551and
1552.q esvax
1553to all be in class
1554.q V ,
1555so that
1556.q $=V
1557on the LHS of a rewriting rule
1558will match any of these words.
1559.sh 3 "F \*- define word class from file"
1560.(b
1561.b F \c
1562.i c\&filename
1563.i format
1564.)b
1565.pp
1566This works analogously
1567to the
1568.b C
1569line except that it reads the contents of the class
1570from the given
1571.i filename .
1572If given,
1573the specified
1574.i format
1575is used as a
1576scanf(3)
1577string which should produce a single string.
1578.sh 2 "A Detailed Example"
1579.pp
1580We will now follow the configuration file
1581in figure 2
1582through in detail.
1583This example is from a version of the configuration file
1584for the IngVAX machine at Berkeley.
1585IngVAX had no interesting network connections.
1586Ing70 had an ARPANET connection,
1587and CSVAX had a UUCP connection.
1588All of these machines were tied together via BerkNet.
1589.sh 3 "Macro definitions"
1590.(b
1591DABerkeley
1592DBIngVAX
1593DUucbvax
1594DnMAILER-DAEMON
1595DlFrom $g  $d
1596Do.:@!^
1597Dq$g$?x ($x)$.
1598.)b
1599The first three macros are for convenience only,
1600and are used to define the local host names
1601on the ARPANET, BerkNet, and the UUCP net
1602respectively.
1603.pp
1604Macro
1605.b n
1606defines the name of
1607.i sendmail
1608when error messages are sent.
1609Macro
1610.b l
1611defines what the first line
1612of a message in UNIX format looks like,
1613in this case the version 7 standard of:
1614.(b
1615From sender-name  time-of-submission
1616.)b
1617The
1618.b o
1619macro
1620tells what characters will be distinct from names
1621when scanning addresses.
1622In this case,
1623dot and colon will be used
1624to distinguish BerkNet addresses,
1625at sign for ARPANET addresses,
1626and exclamation point and caret for UUCP addresses.
1627.sh 3 "Header definitions"
1628.(b
1629H\&Date: $a
1630H\&From: $g$?x ($x)$.
1631H\&Full-Name: $x
1632H\&Message-Id: <$t.$p.$B@$A>
1633H\&Posted-Date: $a
1634.)b
1635These define the headers
1636that may be added to a message.
1637The
1638.q Date:
1639is just the ARPANET idea of the date.
1640The
1641.q From:
1642line is the translated version of the sender,
1643followed by the sender's full name if known.
1644The
1645.q Full-Name:
1646field is used to transmit the sender's full name
1647when a
1648.q From:
1649line is not being sent;
1650these will normally be mutually exclusive.
1651The
1652.q Message-Id:
1653field has the time and process id's concatenated
1654with the BerkNet and ARPANET addresses
1655to make a unique string.
1656Finally, the
1657.q Posted-Date:
1658is the date in ARPANET format;
1659it differs from
1660.q Date:
1661in that it is always output as soon as the message enters
1662.i sendmail 's
1663domain,
1664and hence indicates the time that the message first enters
1665the mail delivery system
1666[Postel79b, NBS80].
1667.sh 3 "Name classifications"
1668.(b
1669C\&A\&ucb berkeley
1670C\&B\&j IngVax
1671C\&C\&i ingres ing70
1672C\&U\&ucbvax ernie
1673.)b
1674These commands put the words
1675.q ucb
1676and
1677.q berkeley
1678into class
1679.q A ,
1680the valid names of this site on the ARPANET.
1681Words
1682.q j
1683and
1684.q ingvax
1685are in class
1686.q B ,
1687the local names on BerkNet.
1688Class
1689.q C ,
1690the names of the site which has the ARPANET link,
1691has the words
1692.q i ,
1693.q ingres ,
1694and
1695.q ing70 .
1696Finally,
1697.q ucbvax
1698and
1699.q ernie
1700are the UUCP names of our UUCP gateway,
1701and are in class
1702.q U .
1703.pp
1704The classes will be used in the patterns of the rewriting rules
1705as described below.
1706.sh 3 "Mailer definitions"
1707.(b
1708.if n .in 0
1709.if t .sz -2
1710.ta \w'M\&local  'u +\w'/usr/net/bin/sendberkmail  'u +\w'rlsAmn  'u +\w'$f@$A  'u
1711M\&local	/bin/mail	rlsAmn	$f	...localmail -d $u
1712M\&prog	/bin/csh	lA	$f	...progmail -fc $u
1713M\&berk	/usr/net/bin/sendberkmail	fxs	$B:$f	...berkmail -m $h -h $c -t $u
1714M\&arpa	/usr/lib/mailers/arpa	sAu	$f@$A	...arpamail $f $h $u
1715M\&uucp	/usr/bin/uux	rsDxmU	$U!$f	...uucpmail - $h!rmail ($u)
1716M\&xlate	/	A	$f	/
1717.if n .in
1718.if t .sz
1719.)b
1720Six mailers are known in the configuration file.
1721There
1722.i must
1723be entries for local and program mail.
1724.pp
1725Local mail is sent using
1726/bin/mail.
1727It takes a
1728.b \-r
1729flag,
1730is local,
1731quote characters are stripped before sending,
1732takes ARPANET standard headers,
1733can deliver to multiple recipients at once,
1734and does not want a UNIX-style
1735.q From
1736line since it will add one itself.
1737The translated
1738.q from
1739address is the same as the raw
1740.q from
1741address,
1742since no network hops are made.
1743The argument vector has a program name,
1744a
1745.b \-d
1746flag (\c
1747.q "really deliver" ,
1748which must be added to /bin/mail),
1749and the list of recipients \*- one recipient per argument.
1750.pp
1751Mail piped through programs
1752is interpreted by /bin/csh.
1753Unlike local mail,
1754it does not take a
1755.b \-r
1756flag,
1757quotes should be left,
1758it can only deal with one user,
1759and it does want a UNIX-style
1760.q From
1761line,
1762but is still local and still wants an ARPANET style header.
1763.pp
1764BerkNet mail is processed by
1765/usr/net/bin/sendberkmail.
1766It takes a
1767.b \-f
1768flag,
1769wants a
1770.q Full-Name:
1771header line,
1772and wants quotes stripped.
1773The
1774.q Full-Name:
1775is used here because if it were given as a comment
1776in a
1777.q From:
1778line the machine address of the sender
1779would not be modified by later instantiations of
1780.i delivermail \**.
1781.(f
1782\**\c
1783.i Delivermail
1784did no header editing,
1785so
1786.q From:
1787lines were always passed untouched.
1788When the gateways are converted to
1789.i sendmail
1790this can be changed.
1791.)f
1792The from address as seen by the receiver is
1793.q IngVAX:sender ,
1794and it takes a flag-oriented
1795rather than a positional
1796command list.
1797.pp
1798The ARPANET wants quotes stripped,
1799ARPANET standard headers,
1800and wants the user name left with case intact.
1801It takes a positional command list.
1802.pp
1803UUCP mail calls
1804.i uux
1805with a
1806.b \-r
1807flag,
1808quotes stripped,
1809a
1810.q Date:
1811line,
1812a
1813.q Full-Name:
1814line,
1815and with multiple users listed.
1816Since UUCP is a relic of the (not so) distant past,
1817it requires ugly header lines.
1818.pp
1819The final entry is a dummy entry to declare the pseudo-mailer
1820.i xlate .
1821When this mailer is found
1822it causes a table lookup to be done in the alias file
1823using the host name as a key.
1824A
1825.q %s
1826in the value part is replaced by the user name.
1827The entire parsing mechanism is restarted when this is encountered.
1828.pp
1829If
1830.q $u
1831were to be missing from the argument vector for a mailer,
1832that mailer would be accessed using the SMTP [Postel81]
1833protocol.
1834.sh 3 "Rewriting rules for recipient addresses"
1835.(b
1836.sz -2
1837.ta \w'[88]  'u +\w'R\&CSVAX:$-h!$+u  'u +\w'$#berk$@ing70$:$+u@$+h  'u
1838[1]	R\&$-.$+	$1:$2	change "." to ":"
1839[2]	R\&$=C:$+@$-	$2@$3	delete ing70: on arpanet addresses
1840[3]	R\&$+@$=A	ing70:$1	delete local arpa hosts
1841[4]	R\&$+@$-	$#berk$@ing70$:$1@$2	send arpa mail to ing70
1842[5]	R\&$+^$+	$1!$2	change "^" to "!"
1843[6]	R\&$-!$=U!$+	csvax:$3	delete uucp loops through csvax
1844[7]	R\&$-!$+	csvax:$1!$2	send uucp mail to csvax
1845[8]	R\&$-:$-:$+	$2:$3	delete multiple berk hosts
1846[9]	R\&$=B:$+	$2	delete local berk hosts
1847[10]	R\&$-:$+	$#berk$@$1$:$2	resolve berk mail
1848[11]	R\&$+	$#local$:$1	resolve local mail
1849.sz
1850.)b
1851The first rule translates dots to colons.
1852Redundant explicit routing to the ARPANET is deleted
1853in the second rule.
1854Hops out over the ARPANET
1855back to us are deleted in the third rule \*-
1856note that the BerkNet host that we would have come in on
1857is inserted.
1858Real ARPANET mail is resolved immediately with no further ado \*-
1859it is sent out over the BerkNet to the ing70,
1860and further rewriting stops immediately.
1861.pp
1862Carets are changed to exclamation points
1863for UUCP addresses in the fifth rule.
1864The sixth rule deletes loops out into UUCP land
1865and back to us \*- noting that we will be left on CSVAX.
1866The seventh rule does forwarding of UUCP mail to the CSVAX.
1867Multiple BerkNet hosts are deleted in rule eight \*-
1868this can occur internally quite easily
1869as a side effect of a rewriting rule.
1870Rule nine deletes local BerkNet hosts.
1871The last two rules resolve BerkNet and local mail
1872by turning them into the canonical form:
1873.(b
1874$#\fInet\fP$@\fIhost\fP$:\fIuser\fP
1875.)b
1876.pp
1877Consider the following examples.
1878The numbers to the left are the rule that is being applied
1879to make the transformation.
1880.(b
1881.re
1882	esvax.asa
1883[1]	esvax:asa
1884[10]	$#berk$@esvax$:asa
1885.)b
1886.(b
1887	research^vax135^dmr
1888[5]	research!vax135^dmr
1889[5]	research!vax135!dmr
1890[7]	$#berk$@csvax$:research!vax135!dmr
1891.)b
1892.(b
1893	research!ucbvax!j:eric
1894[6]	csvax:j:eric
1895[8]	j:eric
1896[9]	eric
1897[11]	$#local$:eric
1898.)b
1899.(b
1900	ing70:wnj@Berkeley
1901[2]	wnj@Berkeley
1902[3]	ing70:wnj
1903[10]	$#berk$@ing70$:wnj
1904.)b
1905.sh 3 "Rewriting rules for sender addresses"
1906.(b
1907.sz -2
1908.ta \w'R\&CSVAX:$-h!$+u  'u +\w'$+u@$+h  'u
1909S\&1
1910R\&ing70:$+@$-	$1@$2	arpanet mail is automatic
1911R\&CSVAX:$-!$+	$1!$2	uucp mail is automatic
1912.sz
1913.)b
1914The
1915.b S
1916line starts putting the rules into set one.
1917These rules strip off the
1918.q ing70:
1919from incoming ARPANET mail
1920and the
1921.q CSVAX:
1922off of incoming UUCP mail.
1923.pp
1924The name classes could be used here,
1925but using literal strings is safe
1926because they will always be program-generated.
1927.sh 1 "COMPARISON WITH OTHER MAILERS"
1928.sh 2 "Delivermail"
1929.pp
1930.i Sendmail
1931is an outgrowth of
1932.i delivermail .
1933The primary differences are:
1934.np
1935Configuration information is not compiled in.
1936This simplifies many of the problems
1937of moving to other machines.
1938It also allows easy debugging of new mailers.
1939.np
1940Address parsing is more flexible.
1941For example,
1942.i delivermail
1943only supported one gateway to any network,
1944whereas
1945.i sendmail
1946can be sensitive to host names
1947and reroute to different gateways.
1948.np
1949Forwarding and
1950:include:
1951features eliminate the requirement that the system alias file
1952be writable by any user
1953(or that an update program be written,
1954or that the system administration make all changes).
1955.np
1956.i Sendmail
1957supports message batching across networks
1958when a message is being sent to multiple recipients.
1959.sh 2 "MMDF"
1960.pp
1961MMDF
1962[Crocker79]
1963spans a wider problem set than
1964.i sendmail .
1965For example,
1966the domain of
1967MMDF includes a
1968.q "phone network"
1969mailer, whereas
1970.i sendmail
1971calls on preexisting mailers in most cases.
1972.pp
1973MMDF and
1974.i sendmail
1975both support aliasing,
1976customized mailers,
1977message batching,
1978automatic forwarding to gateways,
1979queueing,
1980and retransmission.
1981MMDF supports two-stage timeout,
1982which
1983.i sendmail
1984does not currently support.
1985.sh 2 "Message Processing Module"
1986.pp
1987The Message Processing Module (MPM)
1988discussed by Postel [Postel79b]
1989matches
1990.i sendmail
1991closely in terms of its basic architecture.
1992However,
1993like MMDF,
1994the MPM includes the network interface software
1995as part of its domain.
1996.pp
1997MPM also postulates a duplex channel to the receiver,
1998as does MMDF.
1999This allows simpler handling of errors
2000by the mailer
2001than possible in
2002.i sendmail ;
2003when a message queued by
2004.i sendmail
2005is sent,
2006any errors must be returned to the sender
2007by the mailer itself.
2008Both MPM and MMDF mailers
2009can return an immediate error response,
2010and a single error processor can create an appropriate response.
2011.pp
2012MPM prefers passing the message as a structured message,
2013with type-length-value tuples.
2014This implies a much higher degree of cooperation
2015between mailers than required by
2016.i sendmail .
2017MPM also assumes a universally agreed upon internet name space
2018(with each address a net-host-user tuple),
2019which
2020.i sendmail
2021does not.
2022.sh 1 "EVALUATIONS AND FUTURE PLANS"
2023.pp
2024.i Sendmail
2025is designed to work in a nonhomogeneous environment.
2026Every attempt is made to avoid imposing any constraints
2027on the underlying mailers.
2028This goal has driven much of the design.
2029One of the major problems
2030has been the lack of a uniform address space,
2031as postulated in [Postel79a]
2032and [Postel79b].
2033.pp
2034A nonuniform address space implies that path will be specified
2035in all addresses,
2036either explicitly (as part of the address)
2037or implicitly
2038(as with implied forwarding to gateways).
2039This has the unpleasant effect of making replying to messages
2040exceedingly difficult,
2041since there is no one
2042.q address
2043for any person,
2044but only a way to get there from wherever you are.
2045.pp
2046Interfacing to mail programs
2047that were not initially intended to be applied
2048in an internet environment
2049has been amazingly successful,
2050and has reduced the job to a manageable task.
2051.pp
2052.i Sendmail
2053has knowledge of a few difficult environments
2054built in.
2055It generates ARPANET FTP compatible error messages
2056(prepended with three-digit numbers
2057[Neigus73, Postel74])
2058as necessary,
2059optionally generates UNIX-style
2060.q From
2061lines on the front of messages for some mailers,
2062and knows how to parse the same lines on input.
2063This can be inconvenient to sites which have abandoned UNIX mail,
2064although
2065.i sendmail
2066still adds and understands ARPANET-style
2067.q From:
2068lines.
2069Also,
2070error handling has an option customized for BerkNet.
2071.pp
2072One surprisingly major annoyance in most internet mailers
2073(such as MMDF)
2074is that the location and format of local mail is built in\**.
2075.(f
2076\**For example,
2077MMDF puts local mail in the file
2078.q .mail
2079\*- useful if you are running version 6.
2080.)f
2081.i Sendmail
2082eliminates all knowledge of location
2083and can function successfully with different formats.
2084.pp
2085The ability to automatically generate a response to incoming mail
2086(by forwarding mail to a program)
2087seems useful
2088(\c
2089.q "I am on vacation until late August...." )
2090but can create problems
2091such as forwarding loops
2092(two people on vacation whose programs send notes back and forth,
2093for instance)
2094if these programs are not well written.
2095A program should be written to do standard tasks correctly,
2096but this does not solve the general case.
2097It might be desirable to implement some form of load limiting.
2098I am unaware of any mail system that addresses this problem,
2099nor am I aware of any reasonable solution at this time.
2100.pp
2101.i Sendmail
2102should be modified to run as a daemon,
2103reading an MPX file
2104(or other IPC scheme)
2105to receive mail and process it.
2106This would reduce the cost of sending mail to writing the message
2107into a known file.
2108.i Sendmail
2109would be modified to have a very different argument structure.
2110It already has an option to read the recipients
2111from the message header.
2112A more palatable technique for giving error messages
2113would also have to be devised.
2114.pp
2115The configuration file is currently practically inscrutable;
2116considerable convenience could be realized
2117with a higher-level format.
2118For example, a description might read:
2119.(b
2120.re
2121(MACRO name value)
2122(HEADER name value
2123	(OPTION option) ...
2124	(NEEDS option) ... )
2125(MAILER name path xlatstring
2126	(OPTION option) ...
2127	(ARGV arg ... ))
2128(CLASS name word ...)
2129(REWRITE setname
2130	(RULE lhs rhs) ... )
2131.)b
2132.pp
2133It seems clear that common protocols will be changing soon
2134to accommodate changing requirements and environments.
2135These changes will include modifications to the message header
2136[NBS80]
2137or to the body of the message itself
2138(such as for multimedia messages
2139[Postel80]).
2140Other changes will include changes to communication protocols
2141which may effect
2142.i sendmail ;
2143for example, the changes implied by the new Mail Transfer Protocol
2144[Sluizer81].
2145These changes should be relatively trivial to integrate
2146into the existing system.
2147.pp
2148Many other nice features could be implemented.
2149For example,
2150if we were sure that the alias file were writable by the effective user
2151(i.e., if
2152.i sendmail
2153were to run setuid)
2154then the inverted form could be rebuilt automatically when the
2155text copy was changed.
2156However, this appears to be little more than frosting.
2157.pp
2158Some proposals call for a single address syntax,
2159such that the host name uniquely determines the network.
2160There are a number of evident problems with this.
2161In a large internet,
2162the database update problem becomes considerable,
2163especially under multiple managements;
2164this can be solved by a daemon that updates the tables
2165dynamically,
2166but it is not clear what the problems are here.
2167More to the point,
2168this requires a unique namespace among all networks.
2169In our current configuration
2170we have been unable to even find out the names of all the hosts
2171on the UUCP network;
2172to hope that on an internet with fifty or more networks
2173would have no name conflicts is beyond the scope of
2174.i sendmail .
2175Despite the difficulties, however,
2176this is probably a better long-term solution to the problem
2177of internet addressing.
2178The ambiguities implied by addresses combining
2179left-associative and right-associative addresses
2180are impossible to solve without parentheses;
2181acceptable for mathematical equations,
2182but absurd for network addresses.
2183.pp
2184A related problem occurs with the user namespace.
2185In tightly coupled environments,
2186it would be nice to have automatic forwarding between machines
2187on the basis of the user name alone,
2188without cumbersome aliases.
2189This would require an automatically updated database
2190and some method of resolving conflicts.
2191Ideally this would be effective even with multiple managements.
2192A student at Berkeley,
2193Alan Biocca,
2194is working on a facility which may provide the necessary functionality.
2195.pp
2196In the long run,
2197a system that understands canonical internet addresses
2198(net, host, user)
2199implemented in a world that understands these addresses
2200would be an incredible win.
2201.i Sendmail
2202seems to be a useful tool to pull together
2203the haphazard environment that exists today,
2204until the better tools permeate the internetwork world.
2205.sh 0 "ACKNOWLEDGEMENTS"
2206.pp
2207Thanks are due to Kurt Shoens for his continual cheerful
2208assistance and good advice,
2209Bill Joy for pointing me in the correct direction
2210(over and over),
2211and Mark Horton for more advice,
2212prodding,
2213and many of the good ideas.
2214Kurt and Eric Schmidt are to be credited
2215for using
2216.i delivermail
2217as a server for their programs
2218(\c
2219.i Mail
2220and BerkNet respectively)
2221before any sane person should have,
2222and making the necessary modifications
2223promptly and happily.
2224Eric gave me considerable advice about the perils
2225of network software which saved me an unknown
2226amount of work and grief.
2227Mark did the original implementation of the DBM version
2228of aliasing, installed the VFORK code,
2229wrote the current version of
2230.i rmail ,
2231and was the person who really convinced me
2232to put the work into
2233.i delivermail
2234to turn it into
2235.i sendmail .
2236Kurt deserves accolades for using
2237.i sendmail
2238when I was myself afraid to take the risk;
2239how a person can continue to be so enthusiastic
2240in the face of so much bitter reality is beyond me.
2241.pp
2242Kurt and Kirk McKusick
2243read early copies of this paper,
2244giving considerable useful advice.
2245.pp
2246Special thanks are reserved for Mike Stonebraker,
2247who knowingly allowed me to put so much work into this
2248when there were so many other things I really should
2249have been working on.
2250.+c
2251.ce
2252REFERENCES
2253.nr ii 1.5i
2254.ip [Borden79]
2255Borden, S.,
2256Gaines, R. S.,
2257and
2258Shapiro, N. Z.,
2259.ul
2260The MH Message Handling System: Users' Manual.
2261R-2367-PAF.
2262Rand Corporation.
2263October 1979.
2264.ip [Crocker77a]
2265Crocker, D. H.,
2266Vittal, J. J.,
2267Pogran, K. T.,
2268and
2269Henderson, D. A. Jr.,
2270.ul
2271Standard for the Format of ARPA Network Text Messages.
2272RFC 733,
2273NIC 41952.
2274In [Feinler78].
2275November 1977.
2276.ip [Crocker77b]
2277Crocker, D. H.,
2278.ul
2279Framework and Functions of the MS Personal Message System.
2280R-2134-ARPA,
2281Rand Corporation,
2282Santa Monica, California.
22831977.
2284.ip [Crocker79]
2285Crocker, D. H.,
2286Szurkowski, E. S.,
2287and
2288Farber, D. J.,
2289.ul
2290An Internetwork Memo Distribution Facility \*- MMDF.
22916th Data Communication Symposium,
2292Asilomar.
2293November 1979.
2294.ip [Metcalfe76]
2295Metcalfe, R.,
2296and
2297Boggs, D.,
2298.q "Ethernet: Distributed Packet Switching for Local Computer Networks" ,
2299.ul
2300Communications of the ACM 19,
23017.
2302July 1976.
2303.ip [Feinler78]
2304Feinler, E.,
2305and
2306Postel, J.
2307(eds.),
2308.ul
2309ARPANET Protocol Handbook.
2310NIC 7104,
2311Network Information Center,
2312SRI International,
2313Menlo Park, California.
23141978.
2315.ip [NBS80]
2316National Bureau of Standards,
2317.ul
2318Specification of a Draft Message Format Standard.
2319Report No. ICST/CBOS 80-2.
2320October 1980.
2321.ip [Neigus73]
2322Neigus, N.,
2323.ul
2324File Transfer Protocol for the ARPA Network.
2325RFC 542, NIC 17759.
2326In [Feinler78].
2327August, 1973.
2328.ip [Nowitz78a]
2329Nowitz, D. A.,
2330and
2331Lesk, M. E.,
2332.ul
2333A Dial-Up Network of UNIX Systems.
2334Bell Laboratories.
2335In
2336UNIX Programmer's Manual, Seventh Edition,
2337Volume 2.
2338August, 1978.
2339.ip [Nowitz78b]
2340Nowitz, D. A.,
2341.ul
2342Uucp Implementation Description.
2343Bell Laboratories.
2344In
2345UNIX Programmer's Manual, Seventh Edition,
2346Volume 2.
2347October, 1978.
2348.ip [Postel74]
2349Postel, J.,
2350and
2351Neigus, N.,
2352Revised FTP Reply Codes.
2353RFC 640, NIC 30843.
2354In [Feinler78].
2355June, 1974.
2356.ip [Postel77]
2357Postel, J.,
2358.ul
2359Mail Protocol.
2360NIC 29588.
2361In [Feinler78].
2362November 1977.
2363.ip [Postel79a]
2364Postel, J.,
2365.ul
2366Internet Message Protocol.
2367RFC 753,
2368IEN 85.
2369Network Information Center,
2370SRI International,
2371Menlo Park, California.
2372March 1979.
2373.ip [Postel79b]
2374Postel, J. B.,
2375.ul
2376An Internetwork Message Structure.
2377In
2378.ul
2379Proceedings of the Sixth Data Communications Symposium,
2380IEEE.
2381New York.
2382November 1979.
2383.ip [Postel80]
2384Postel, J. B.,
2385.ul
2386A Structured Format for Transmission of Multi-Media Documents.
2387RFC 767.
2388Network Information Center,
2389SRI International,
2390Menlo Park, California.
2391August 1980.
2392.ip [Postel81]
2393Postel, J. B.,
2394.ul
2395Simple Mail Transfer Protocol.
2396RFC788.
2397Network Information Center,
2398SRI International,
2399Menlo Park, California.
2400November 1981.
2401.ip [Schmidt79]
2402Schmidt, E.,
2403.ul
2404An Introduction to the Berkeley Network.
2405University of California, Berkeley California.
24061979.
2407.ip [Shoens79]
2408Shoens, K.,
2409.ul
2410Mail Reference Manual.
2411University of California, Berkeley.
2412In UNIX Programmer's Manual,
2413Seventh Edition,
2414Volume 2C.
2415December 1979.
2416.ip [Sluizer81]
2417Sluizer, S.,
2418and
2419Postel, J. B.,
2420.ul
2421Mail Transfer Protocol.
2422RFC 780.
2423Network Information Center,
2424SRI International,
2425Menlo Park, California.
2426May 1981.
2427.ip [UNIX80]
2428.ul
2429The UNIX Programmer's Manual, Seventh Edition,
2430Virtual VAX-11 Version,
2431Volume 1.
2432Bell Laboratories,
2433modified by the University of California,
2434Berkeley California.
2435November 1980.
2436.++ A
2437.+c "SENDMAIL USAGE"
2438.pp
2439Arguments must be presented with flags before addresses.
2440The flags are:
2441.nr ii 1i
2442.ip "\-f addr"
2443The sender's machine address is
2444.i addr .
2445This flag is ignored unless the real user
2446is root,
2447network,
2448or uucp,
2449or if
2450.i addr
2451contains an exclamation point
2452(because of certain restrictions in UUCP).
2453.ip "\-r addr"
2454An obsolete form of
2455.b \-f .
2456.ip "\-h cnt"
2457Sets the
2458.q "hop count"
2459to
2460.i cnt .
2461This represents the number of times this message has been processed
2462by
2463.i sendmail
2464(to the extent that it is supported by the underlying networks).
2465.i Cnt
2466is incremented during processing,
2467and if it reaches
2468MAXHOP
2469(currently 30)
2470.i sendmail
2471throws away the message with an error.
2472.ip "\-F\&name"
2473Sets the full name of this user to
2474.i name .
2475.ip \-e\&p
2476Print error messages (default).
2477.ip \-e\&q
2478Throw away error messages.
2479The only response is the exit status.
2480.ip \-e\&m
2481Mail back errors.
2482.ip \-e\&w
2483.q Write
2484back errors \*- or mail them if the user is not logged in.
2485.ip \-e\&e
2486Do special error processing for BerkNet.
2487This involves mailing back the errors
2488but always returning a zero exit status.
2489.ip \-n
2490Don't do aliasing or forwarding.
2491.ip \-m
2492Include me in alias expansions.
2493Normally
2494.i sendmail
2495suppresses the sender
2496if in a group being sent to.
2497.ip \-o
2498Assume that the headers are already in new format,
2499i.e.,
2500there are commas between names and spaces are to be preserved.
2501If this flag is not given,
2502an adaptive algorithm is used:
2503if any recipient address contains a comma, parenthesis,
2504or angle bracket,
2505it will be assumed that commas already exist.
2506This flag is required in certain rare cases.
2507Headers are always output with commas between the names.
2508.ip \-i
2509Don't take a dot to end a message.
2510.ip \-t
2511Read the header for
2512.q To: ,
2513.q Cc: ,
2514and
2515.q Bcc:
2516lines, and send to everyone listed in those lists.
2517The
2518.q Bcc:
2519line will be deleted before sending.
2520Any addresses in the argument vector will be deleted
2521from the send list.
2522.ip \-a
2523Do special processing for the
2524ARPANET.
2525This includes reading the
2526.q "From:"
2527line from the header to find the sender,
2528printing
2529ARPANET
2530style messages
2531(preceded by three digit reply codes for compatibility with
2532the FTP protocol
2533[Neigus73, Postel74, Postel77]),
2534and ending lines of error messages with <CRLF>.
2535.ip \-a\&s
2536Take input over an SMTP connection on standard input and output.
2537This does everything the \-a flag does also.
2538.ip \-s
2539Save UNIX-style
2540.q From
2541lines at the beginning of headers.
2542Normally they are assumed redundant
2543and discarded.
2544.ip \-v
2545Give a blow-by-blow description of function.
2546This gives information of interest to the user
2547rather than for the
2548.i sendmail
2549maintainer;
2550for example,
2551aliases are printed as expanded
2552and mailer functions are printed as they run.
2553.ip \-c
2554If this mailer is marked as being expensive,
2555don't connect immediately.
2556This requires that queueing be compiled in,
2557since it will depend on a sender process to
2558actually send the mail.
2559.ip \-q\&time
2560Try to execute the queued up mail.
2561If the time is given,
2562a sendmail will run through the queue at the specified interval
2563to deliver queued mail;
2564otherwise, it only runs once.
2565.ip \-p
2566Verify as much about the addresses and message as possible
2567and then politely run in background.
2568.ip \-D
2569Run as a daemon.
2570This should always be used with the
2571.b \-as
2572flag,
2573as it runs on the SMTP port.
2574.ip \-T\&time
2575Set timeout interval for mail that cannot be sent.
2576.ip \-Q\&dir
2577Select directory in which mail will be queued.
2578Typically for debugging only.
2579.ip \-C\&file
2580Use a different configuration file.
2581.ip \-A\&file
2582Use a different alias file.
2583.ip \-I
2584Initialize the DBM version
2585of the alias file.
2586If
2587.b \-I
2588is given,
2589no delivery is attempted.
2590The DBM version will be rebuilt automatically if the DBM files
2591are mode 666,
2592or if they are owned by the effective userid.
2593.ip \-V
2594Verify the addresses only.
2595Only partial verification is done:
2596syntax is checked, and local names are verified,
2597but no checking normally done by the mailer is attempted.
2598.ip \-d\&level
2599Set debugging level.
2600.ip \-M\&x\&val
2601Define macro
2602.i x
2603to have value
2604.i val .
2605.nr ii 5n
2606.+c "OTHER CONFIGURATION"
2607.pp
2608There are some configuration changes that can be made by
2609recompiling
2610.i sendmail .
2611Some of these are changes to compilation flags:
2612.nr ii 1i
2613.ip V6
2614If set,
2615this will compile a version 6 system,
2616with 8-bit user id's,
2617single character tty id's,
2618etc.
2619If not set,
2620a version 7 system is assumed.
2621.ip DBM
2622If set,
2623the
2624.q DBM
2625package in UNIX is used
2626(see DBM(3X) in [UNIX80]).
2627If not set,
2628a much less efficient algorithm for processing aliases is used.
2629.ip VFORK
2630Set if your system has the experimental
2631.i vfork
2632system call.
2633See vfork(2) in [UNIX80].
2634If not set,
2635the regular
2636.i fork
2637system call is used.
2638This option improves performance.
2639.ip DEBUG
2640If set, debugging information is compiled in.
2641To actually get the debugging output,
2642the
2643.b \-d
2644flag must be used.
2645.ip LOG
2646If set,
2647the
2648.i syslog
2649routine in use at some sites is used.
2650This makes an informational log record
2651for each message processed,
2652and makes a higher priority log record
2653for internal system errors.
2654.ip QUEUE
2655This flag should be set to compile in the queueing code.
2656If this is not set,
2657mailers must accept the mail immediately
2658or it will be returned to the sender.
2659.ip SMTP
2660If set,
2661the code to handle user and server SMTP will be compiled in.
2662This is only necessary if your machine has some mailer
2663that speaks SMTP.
2664.ip UGLYUUCP
2665If you have a UUCP host adjacent to you which is not running
2666a reasonable version of
2667.i rmail ,
2668you will have to set this flag to include the
2669.q "remote from sysname"
2670info on the from line.
2671Otherwise, UUCP gets confused about where the mail came from.
2672.ip PARANOID
2673There are places where
2674.i sendmail
2675may opt for a more secure,
2676but probably less convenient environment.
2677For example,
2678if this flag is set
2679it is not possible to specify a program as an address directly;
2680this can only be done with an alias.
2681.ip NOTUNIX
2682If you are using a non-UNIX mail format,
2683you can set this flag to turn off special processing
2684of UNIX-style
2685.q "From "
2686lines.
2687.nr ii 5n
2688.pp
2689Not all header semantics are defined in the configuration file.
2690Header lines that should only be included by certain mailers
2691(as well as other more obscure semantics)
2692must be specified in the
2693.i HdrInfo
2694table in
2695.i conf.c .
2696This table contains the header name
2697(which should be in all lower case),
2698a set of header control flags (described below),
2699and a set of mailer flags,
2700used by some of the header flags.
2701The header flags are:
2702.nr ii \w'H_ACHECK  'u
2703.ip H_CHECK
2704Check the flags for the receiving mailer
2705against the third field in the
2706.i HdrInfo
2707entry.
2708If the mailer has any of those bits set,
2709send this field;
2710otherwise, do not send this field to that mailer.
2711If the field was in the message originally, however,
2712it will always be sent
2713(i.e., this only applies to headers being added by
2714.i sendmail ).
2715.ip H_ACHECK
2716Same as H_CHECK,
2717except that it even applies to headers that were in the
2718original message.
2719That is,
2720if this bit is set and the mailer does not have flag bits set
2721that intersect with the third field in this
2722.i HdrInfo
2723entry,
2724the header line is
2725.i always
2726deleted.
2727.ip H_EOH
2728If this header field is set,
2729treat it like a blank line,
2730i.e.,
2731it will signal the end of the header
2732and the beginning of the message text.
2733.ip H_FORCE
2734Add this header entry
2735even if one existed in the message before.
2736If a header entry does not have this bit set,
2737.i sendmail
2738will not add another header line if a header line
2739of this name already existed.
2740This would normally be used to stamp the message
2741by everyone who handled it.
2742.ip H_RCPT
2743If set,
2744this field contains recipient addresses.
2745This is used by the
2746.b \-t
2747flag to determine who to send to
2748when it is collecting recipients from the message.
2749.ip H_ADDR
2750This flag indicates that this field
2751contains addresses that should be rewritten
2752to include commas, etc.
2753.nr ii 5n
2754.lp
2755Let's look at a sample
2756.i HdrInfo
2757specification:
2758.(b
2759.sz -2
2760.ta 4n +\w'"received-from",  'u +\w'H_ADDR|H_ACHECK,  'u
2761struct hdrinfo	HdrInfo[] =
2762{
2763	"date",	H_CHECK,	M_NEEDDATE,
2764	"from",	H_CHECK,	M_NEEDFROM,
2765	"original-from",	H_ACHECK,	0,
2766	"sender",	0,	0,
2767	"full-name",	H_ACHECK,	M_FULLNAME,
2768	"to",	H_ADDR,	0,
2769	"cc",	H_ADDR,	0,
2770	"bcc",	H_ADDR|H_ACHECK,	0,
2771	"message-id",	H_CHECK,	M_MSGID,
2772	"message",	H_EOH,	0,
2773	"text",	H_EOH,	0,
2774	"received-date",	H_CHECK,	M_LOCAL,
2775	"received-from",	H_CHECK,	M_LOCAL,
2776	"via",	H_FORCE,	0,
2777	NULL,	0,	0,
2778};
2779.sz
2780.)b
2781This specification says that the
2782.q Date: ,
2783.q From: ,
2784.q Message-Id: ,
2785.q Received-Date: ,
2786and
2787.q Received-From:
2788must be requested by the mailer to be inserted.
2789However,
2790if they were in the message as received by
2791.i sendmail
2792they will be propagated.
2793The
2794.q Full-Name:
2795field, on the other hand,
2796will be deleted even if it was specified before,
2797unless the mailer wants it.
2798The
2799.q Original-From:
2800and
2801.q Bcc:
2802fields will be deleted unconditionally
2803(since it is never possible for a mailer's flags
2804to intersect with zero).
2805The
2806.q Original-From:
2807is in fact used internally,
2808and will be reinserted by ad hoc code,
2809but only if it differs from the
2810.q From:
2811line that would otherwise be inserted.
2812.q To: ,
2813.q Cc: ,
2814and
2815.q Bcc:
2816all specify recipient addresses.
2817The
2818.q Message:
2819and
2820.q Text:
2821fields will terminate the header;
2822these are specified in new protocols
2823[NBS80]
2824or used by random dissenters around the network world.
2825The
2826.q Via:
2827field will always be added,
2828and can be used to trace messages.
2829The
2830.q Sender:
2831field is used internally,
2832although no cliched special processing occurs.
2833.pp
2834There are a number of important points here.
2835First,
2836header fields are not added automatically just because they are in the
2837.i HdrInfo
2838structure;
2839they must be specified in the configuration file
2840in order to be added to the message.
2841Any header fields mentioned in the configuration file but not
2842mentioned in the
2843.i HdrInfo
2844structure have default processing performed;
2845that is,
2846they are added unless they were in the message already.
2847Second,
2848the
2849.i HdrInfo
2850structure only specifies cliched processing;
2851certain headers are processed specially by ad hoc code
2852regardless of the status specified in
2853.i HdrInfo .
2854For example,
2855the
2856.q Sender:
2857and
2858.q From:
2859fields are always scanned on ARPANET mail
2860to determine the sender;
2861this is used to perform the
2862.q "return to sender"
2863function.
2864The
2865.q "From:"
2866and
2867.q "Full-Name:"
2868fields are used to determine the full name of the sender
2869if possible;
2870this is stored in the macro
2871.b $x
2872and used in a number of ways.
2873Although the
2874.q "Original-From:"
2875field is specified to be deleted in
2876.i HdrInfo ,
2877it is added automatically if the
2878.q From:
2879field that would be generated internally
2880differs from the
2881.q From:
2882field that was specified in the message;
2883in this case,
2884the original
2885.q From:
2886field is renamed
2887.q Original-From: .
2888.pp
2889The file
2890.i conf.c
2891also contains the specification of ARPANET reply codes.
2892There are six classifications these fall into:
2893.(b
2894.sz -2
2895.ta \w'char  'u +\w'Arpa_Usrerr[] =  'u +\w'"888";  'u
2896char	Arpa_Info[] =	"050";	/* arbitrary info */
2897char	Arpa_Enter[] =	"350";	/* start mail input */
2898char	Arpa_Mmsg[] =	"256";	/* mail successful (MAIL cmd) */
2899char	Arpa_Fmsg[] =	"250";	/* mail successful (MLFL cmd) */
2900char	Arpa_Syserr[] =	"455";	/* some (transient) system error */
2901char	Arpa_Usrerr[] =	"450";	/* some (fatal) user error */
2902.sz
2903.)b
2904The class
2905.i Arpa_Info
2906is for any information that is not required by the protocol,
2907such as forwarding information.
2908.i Arpa_Enter
2909is output when
2910.i sendmail
2911wants to start receiving the mail.
2912.i Arpa_Mmsg
2913and
2914.i Arpa_Fmsg
2915are given if the mail is successfully delivered;
2916the selection of message number depends on the FTP command given
2917(which is communicated via the
2918.b \-a
2919flag).
2920.i Arpa_Syserr
2921is printed by the
2922.i syserr
2923routine;
2924typically, this occurs when something has gone wrong at the
2925receiving site,
2926with the assumption that it is a transient condition.
2927Finally,
2928.i Arpa_Usrerr
2929is the result of a user error
2930and is generated by the
2931.i usrerr
2932routine;
2933these are generated when the user has specified something wrong,
2934and hence the error is permanent,
2935i.e.,
2936it will not work simply by resubmitting the request.
2937.pp
2938If it is necessary to restrict mail through a gateway,
2939the
2940.i checkcompat
2941routine can be modified.
2942This routine is called for every recipient address.
2943It can return
2944.b TRUE
2945to indicate that the address is acceptable
2946and mail processing will continue,
2947or it can return
2948.b FALSE
2949to reject the recipient.
2950If it returns false,
2951it is up to
2952.i checkcompat
2953to print an error message
2954(using
2955.i usrerr )
2956saying why the message is rejected.
2957For example,
2958.i checkcompat
2959could read:
2960.(b
2961.re
2962.sz -2
2963bool
2964checkcompat(to)
2965	register ADDRESS *to;
2966{
2967	if (MsgSize > 50000 && to->q_mailer != MN_LOCAL)
2968	{
2969		usrerr("Message too large for non-local delivery");
2970		return (FALSE);
2971	}
2972	return (TRUE);
2973}
2974.sz
2975.)b
2976This would reject messages greater than 50000 bytes
2977unless they were local.
2978The actual use of this routine is highly dependent on the
2979implementation,
2980and use should be limited.
2981