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