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