1.nr DR 1 2.he 'SENDMAIL''%' 3.if \n(DR .fo 'For Your Eyes Only'\*-DRAFT\*-'\*(td' 4.ls 2 5.+c 6.(l C 7.sz 12 8SENDMAIL \*- An Internet Mail Router 9.sz 10.sp 11Eric Allman 12.i 13Project INGRES 14Electronics Research Lab 15University of California 16Berkeley, California 94720 17.)l 18.(f 19This is 20.if \n(DR draft 21version 3.1, 22last modified on 08/24/81. 23.if \n(DR Please do not distribute this version without permission 24.if \n(DR of the author. 25.)f 26.sp 2 27.pp 28.i Sendmail 29implements a general internetwork mail routing facility. 30Features include aliasing and forwarding, 31automatic routing to network gateways, 32and flexible configuration. 33.pp 34Section 1 discusses the design goals for 35.i sendmail . 36Section 2 gives an overview of the basic functions of the system. 37In section 3, 38details of usage are discussed. 39A detailed description of the configuration file 40is given in section 4, 41including a walkthrough of a specific configuration file. 42Section 5 compares 43.i sendmail 44to other internet mail routers, 45and an evaluation of 46.i sendmail 47is given in section 6, 48including future plans. 49.sh 1 "DESIGN GOALS" 50.pp 51.i Sendmail 52was an outgrowth of 53.i delivermail, 54a previous incarnation of a UNIX internetwork mail router. 55.i Delivermail 56was written relatively quickly. 57The first version only knew about taking apart addresses 58for explicit forwarding 59and limited aliasing; 60automatic forwarding and other features 61came later. 62.pp 63Design goals for 64.i delivermail 65included: 66.np 67Compatibility with the existing mail system, 68including Bell version 6 mail, 69Bell version 7 mail, 70Berkeley mail, 71BerkNet mail, 72and hopefully UUCP mail. 73ARPANET mail was also required, 74and the difference in format 75drove the decision to put all such formatting 76into the low-level mailer. 77.np 78Because of time constraints, 79utilize as much existing software as possible. 80The changes to the existing software were minimal: 81Berkeley mail, 82BerkNet, 83UUCP, and the ARPANET FTP server 84had to be modified to call 85.i delivermail 86as their server instead of 87/bin/mail 88(or in the case of the ARPANET, 89writing the mail into a file 90which has no meaning to standard UNIX mailers). 91The only major modifications 92were to /bin/mail, 93which was maintained both as a user interface sender 94and as a 95.i delivermail 96mailer. 97As a sender, 98it calls 99.i delivermail . 100.i Delivermail 101calls it in turn to do local delivery, 102so a 103.b \-d 104flag was added to avoid loops. 105.np 106Reliability was considered essential 107because of the emphasis on mail in our environment. 108This turned out to be one of the hardest goals to satisfy, 109especially in the face of the many anomalous message formats 110produced by various ARPANET sites. 111For example, 112MIT and CMU allow mail from people who are not logged in 113(and which have meaningless from addresses), 114which caused error message loops. 115WHARTON changes our host name from 116.q Berkeley 117to 118.q Berkel- 119which creates interesting problems under certain circumstances \*- 120not to mention rendering any 121.q reply 122feature unworkable. 123CMU puts blanks in names, 124which created amazing problems, 125since many UNIX mail programs assume that an address 126is one word. 127And at least one person lists his address as 128.q "From: the TTY of ..." , 129giving a 130.q Sender: 131field with his real address. 132In summary, 133the obscure aspects of the ARPANET mail protocol 134really are used, 135are difficult to support, 136but must be supported. 137.pp 138There were certain non-goals in 139.i delivermail 140also. 141Many of these resulted from the expectation that 142it would only be used at Berkeley, 143and probably only at a few sites at Berkeley. 144.np 145It was fair game to compile configuration information 146into the code, 147even to assume that they were running BerkNet. 148.np 149The problem of multiple connections to a single network 150was not foreseen. 151For example, 152on a host with no UUCP connection, 153all UUCP mail was sent to a single host. 154In fact, 155Berkeley is running UUCP on at least three hosts. 156.np 157No attempt was made to reduce the volume of mail across a network link. 158Besides the difficulty of doing this, 159we failed to appreciate how much volume there would be. 160.pp 161.i Sendmail 162maintained the goals of 163.i delivermail. 164Time was less of a constraint, 165but not reimplementing the wheel 166(or other mailers) 167had proven to be a wise move in many ways. 168For example, 169many internet mailers deliver local mail directly. 170This is more efficient, 171but builds in the design decisions 172of the local mailer, 173and makes it difficult to concentrate 174on the 175.q "real problems" 176(such as locking). 177Other design goals were: 178.np 179.i Sendmail 180should operate in more complex environments, 181including multiple 182(but not equivalent) 183connections to a single network. 184This required that the contents of a host field 185be considered, 186as well as just the syntax of an address. 187This results both from a desire to simplify use by other sites, 188and to anticipate the environment Berkeley is moving towards. 189.np 190Configuration should not be compiled into the code. 191A single binary should be able to run as is at any site 192(modulo such basic changes as the CPU type or the operating system). 193We have found this apparently unimportant goal 194to be critical in real life. 195.np 196.i Delivermail 197only knows about one alias file. 198Berkeley is a sufficiently open environment 199that this can be writable by everyone, 200but other environments are not so lax. 201Thus, 202.i sendmail 203must be able to let various groups maintain their own mailing lists, 204and individuals their own forwarding, 205without writing the system alias file. 206.np 207Customized incoming mailers should be supported. 208.np 209Network traffic should be minimized 210by batching addresses to a single host where possible, 211without assistance by the user. 212.sh 1 "OVERVIEW" 213.sh 2 "System Organization" 214.pp 215.i Sendmail 216neither interfaces with the user 217nor does actual mail delivery. 218Rather, 219it collects a message 220generated by a user interface program (UIP), 221does editing as required by the internet environment, 222and calls appropriate mailers 223to do mail delivery or queueing for network transmission 224(the exception is when mailing to a file). 225This discipline allows the insertion of new mailers 226at minimum cost. 227In this sense it is like the Message Processing Module (MPM) 228of [1]. 229.(d 230[1] Postel -- internet message structure 231.)d 232See Figure 1. 233.(z 234.(c 235 +-------+ 236 | user | 237 +-------+ 238 | 239 +-----+ 240 | UIP | 241 +-----+ 242 | 243 +-----------+ 244 | sendmail | 245 +-----------+ 246 | | | 247 +----------+ + +----------+ 248 | | | 249+---------+ +---------+ +---------+ 250| mailer | | mailer | | mailer | 251+---------+ +---------+ +---------+ 252.)c 253 254.ce 255Figure 1 \*- System Structure. 256.)z 257.sh 2 "Operational Description" 258.sh 3 "Argument processing and address parsing" 259.pp 260The arguments are first scanned, 261and flag arguments are processed. 262The remaining arguments are addresses. 263They are parsed in turn, 264and a list of recipients is created. 265Aliasing is done at this step. 266As much validity checking of the addresses as possible 267is done at this step. 268Syntax is checked, and local addresses can be verified, 269but detailed checking of host names and addresses 270is not checked until later. 271Forwarding is also done 272as the local addresses are verified. 273.pp 274As each address is parsed, 275it is appended to the recipient list. 276When a name is aliased or forwarded, 277the old name is not removed from the list, 278but a flag is set in the address header 279that tells the delivery phase 280to not actually deliver the message to this recipient. 281This list is kept without duplicates, 282preventing alias loops 283and eliminating people receiving two copies of a message, 284as might happen if a person were in two groups. 285.pp 286The recipient list is kept partitioned by mailer; 287this simplifies the task of sending one copy of a message 288across network links. 289.sh 3 "Message collection" 290.pp 291The message is then collected from the standard input. 292Parsing of the message header is done at this point. 293The header is stored in memory, 294and the body of the message is saved 295in a temp file. 296.pp 297Collection occurs even if no addresses were valid 298to simplify program interface. 299The message will be returned with an error. 300.sh 3 "Message delivery" 301.pp 302For each mailer known to the system, 303the part of the recipient list for this mailer is scanned. 304For each unique host, 305a call is made to the mailer. 306Each call contains the users on that host. 307Mailers that only accept one recipient at a time 308are handled properly. 309.pp 310.i Sendmail 311then forks a process for each mailer 312with a non-empty send list. 313The message is then sent to the mailer 314(which must read its standard input) 315prepended by a customized header. 316The exit code is caught and checked, 317and a suitable error message given as appropriate. 318The exit code must conform to a system standard 319or a meaningless message 320(\c 321.q "Service unavailable" ) 322is given. 323.pp 324Delivery to files is handled directly. 325.sh 3 "Return to sender" 326.pp 327If errors occurred during processing, 328the message is returned to the sender for retransmission. 329The letter can be mailed back 330or written in the file 331.q dead.letter 332in the sender's home directory. 333.sh 2 "Configuration File" 334.pp 335Almost all configuration information is read at runtime 336from an ASCII file. 337Information encoded in this file includes 338macro definitions, 339header declarations, 340mailer definitions, 341and address rewriting rules. 342.sh 3 Macros 343.pp 344Macros can be used in three ways. 345Certain macros transmit 346unstructured textual information 347into the mail system, 348such as the name 349.i sendmail 350will use to identify itself in error messages. 351Other macros transmit information from 352.i sendmail 353to the configuration file 354for use in creating other fields 355(such as argument vectors to mailers); 356examples of these are the name of the sender and the host and user 357of the recipient. 358Other macros are unused internally, 359and can be used as shorthand in the configuration file. 360.sh 3 "Header declarations" 361.pp 362Header declarations declare to 363.i sendmail 364the set of known header lines. 365Knowledge of a few header lines 366is built into 367.i sendmail , 368such as the 369.q From: 370and 371.q Date: 372lines. 373.pp 374Most headers declared in the configuration file 375will be automatically inserted 376in the outgoing message 377if they don't exist in the incoming message. 378Certain headers are suppressed by some mailers. 379.sh 3 "Mailer declarations" 380.pp 381Mailer declarations tell 382.i sendmail 383of the various mailers available to it. 384The definition includes the internal name of the mailer, 385the pathname of the program to call, 386some flags associated with the mailer, 387and an argument vector to be used on the call; 388this vector is macro expanded before use. 389.sh 3 "Address rewriting rules" 390.pp 391The heart of address parsing in 392.i sendmail 393is the rewriting rules. 394These are an ordered list of pattern-replacement rules. 395Each address is applied successively to these rules 396until it resolves into a canonical address 397(i.e., 398a [mailer, host, user] 3993-tuple), 400or it falls off the end. 401When a pattern matches, 402the rule is reapplied until it fails. 403.sh 2 "Message Header Editing" 404.pp 405Certain editing of the message header 406occurs automatically. 407Header lines can be inserted 408under control of the configuration file. 409Some lines can be merged; 410for example, 411a 412.q From: 413line and a 414.q Full-name: 415line can be merged under certain circumstances. 416.sh 1 USAGE 417.sh 2 "Arguments" 418.pp 419Arguments must be presented with flags before addresses. 420The flags are: 421.nr ii 1i 422.ip "\-f addr" 423The mail is from 424.i addr . 425This flag is ignored unless the real user 426is root, 427network, 428or uucp, 429or if 430.i addr 431contains an exclamation point 432(because of certain restrictions in UUCP). 433.ip "\-r addr" 434An obsolete form of 435.b \-f . 436.ip "\-h cnt" 437Sets the 438.q "hop count" 439to 440.i cnt . 441This represents the number of times this message has been processed 442by 443.i sendmail 444(to the extent that it is supported by the underlying networks). 445.i Cnt 446is incremented during processing, 447and if it reaches 448MAXHOP 449(currently 30) 450.i sendmail 451throws away the message with an error. 452.ip "\-F\&name" 453Sets the full name of this user to 454.i name . 455.ip \-e\&p 456Print error messages (default). 457.ip \-e\&q 458Throw away error messages. 459The only response is the exit status. 460.ip \-e\&m 461Mail back errors. 462.ip \-e\&w 463.q Write 464back errors \*- or mail them if the user is not logged in. 465.ip \-e\&e 466Do special error processing for BerkNet. 467This involves mailing back the errors 468but always returning a zero exit status. 469.ip \-n 470Don't do aliasing or forwarding. 471.ip \-m 472Include me in alias expansions. 473Normally 474.i sendmail 475suppresses the sender 476if in a group being sent to. 477.ip \-i 478Don't take a dot to end a message. 479.ip \-t 480Read the header for 481.q To: , 482.q Cc: , 483and 484.q Bcc: 485lines, and send to everyone listed in those lists. 486The 487.q Bcc: 488line will be deleted before sending. 489.ip \-a\&m 490Do special processing for the 491ARPANET. 492This includes taking the 493.q "From:" 494person from the header, 495printing 496ARPANET 497style messages 498(preceded by three digits), 499and ending lines with <CRLF>. 500.ip \-a\&f 501Same as 502.b \-a\&m , 503except print out message numbers appropriate for the MLFL command. 504.ip \-s 505Save UNIX-style 506.q From 507lines at the beginning of headers. 508Normally they are assumed redundant 509and discarded. 510.ip \-v 511Give a blow-by-blow description of function. 512This gives information of interest to the user 513rather than for the 514.i sendmail 515maintainer; 516for example, 517aliases are printed as expanded 518and mailer functions are printed as they run. 519.ip \-C\&file 520Use a different configuration file. 521.ip \-A\&file 522Use a different alias file. 523.ip \-I 524Initialize the DBM version 525of the alias file. 526If 527.b \-I 528is given, 529no delivery is attempted. 530.ip \-V 531Verify the addresses only. 532Only partial verification is done: 533syntax is checked, and local names are verified, 534but no checking normally done by the mailer is attempted. 535.ip \-d\&level 536Set debugging level. 537.ip \-D\&x\&val 538Define macro 539.i x 540to have value 541.i val . 542.nr ii 5n 543.pp 544Following flag arguments, 545address arguments may be given. 546These follow the syntax in RFC733 547[7] 548.(d 549[7] RFC733 550.)d 551for ARPANET 552address formats. 553In brief, the format is: 554.np 555Anything in parentheses is thrown away 556(as a comment). 557.np 558Anything in angle brackets (\ <>\ ) is preferred 559over anything else. 560.np 561Double quotes 562(\ "\ ) 563quote phrases; 564backslashes quote characters. 565Backslashes are more powerful \*- for example, 566.i user 567and 568.i 569"user" 570.r 571are equivalent, 572but 573.i \euser 574is different from either of them. 575.np 576The word 577.q at 578is converted to 579.q @ . 580.pp 581All other processing is controlled by the rewriting rules 582(disclaimer: some special processing is done 583after rewriting local names). 584Parentheses, angle brackets, and double quotes 585must be properly balanced and nested. 586.sh 2 "Aliasing, Forwarding, Inclusion" 587.pp 588.i Sendmail 589supports three methods for implicitly rerouting mail. 590Aliasing applies system wide. 591Forwarding allows each user to reroute incoming mail 592destined for that account. 593Inclusion directs 594.i sendmail 595to read a file for a list of addresses, 596and would normal be used 597in conjunction with aliasing. 598.sh 3 "Aliasing" 599.pp 600Aliasing uses a system-wide file 601mapping names to address lists. 602This file is inverted to speed access. 603Only names that appear to be local 604are allowed as aliases; 605this guarantees a unique key. 606.pp 607The inverted form of the file 608must be recreated when the text copy is changed. 609The 610.b \-I 611option to 612.i sendmail 613rebuilds the database. 614.sh 3 "Forwarding" 615.pp 616After aliasing, 617users that are found to be local and valid 618are checked for the existence of a 619.q .forward 620file in their home directory. 621If it exists, 622the message is 623.i not 624sent to that user, 625but rather to the list of users in that file. 626The expectation is that this will normally 627be one user only, 628and the use will be for network mail forwarding. 629.pp 630Forwarding also permits a user to specify a private incoming mailer. 631For example, 632forwarding to: 633.(b 634"\^|\|/usr/local/newmail myname" 635.)b 636will use a different incoming mailer. 637.sh 3 "Inclusion" 638.pp 639Inclusion is specified in ARPANET syntax: 640.(b 641:Include: pathname 642.)b 643An address of this form reads the file specified by 644.i pathname 645and sends to all users listed in that file. 646.pp 647The intent is 648.i not 649to support direct use of this feature, 650but rather to use this as a subset of aliasing. 651For example, 652an alias of the form: 653.(b 654project: :include:/usr/project/userlist 655.)b 656is a method of letting a project maintain a mailing list 657without interaction with the system administration, 658even if the alias file is protected. 659.pp 660It is not necessary to rebuild the alias database 661when a :include: list is changed. 662.sh 2 "Exit Status" 663.pp 664An exit status is returned that corresponds to the system standard 665used by the other mailers. 666.sh 1 CONFIGURATION 667.pp 668Configuration is controlled primarily by the file 669/usr/lib/sendmail.cf. 670.i Sendmail 671should not need to be recomplied except 672.np 673To change operating systems 674(V6, V7/32V, 4BSD). 675.np 676To remove or insert the DBM library. 677.np 678To change ARPANET reply codes. 679.np 680To add headers requiring special processing. 681.lp 682Adding mailers or changing parsing or routing information 683does not require recompilation. 684.pp 685If the mail is being sent by a local user, 686and the file 687.q .mailcf 688exists in the sender's home directory, 689that file is read as a configuration file 690after the system configuration file. 691The primary use of this is to add header lines. 692.sh 2 "Configuration File Description" 693.pp 694The configuration file is formatted 695as a series of text lines, 696each beginning with a character describing its semantics. 697Blank lines and lines beginning with a sharp sign 698(#) 699are ignored. 700.pp 701See figure 2 for an example configuration file. 702.(z 703########################################## 704# sendmail configuration file 705# @(#)sendmail.cf 3.6 8/17/81 706########################################## 707 708### local hosts on various nets 709DABerkeley 710DBIngVAX 711DUucbvax 712 713### special macros 714# my name 715D\&n\&MAILER-DAEMON 716# UNIX header format 717D\&l\&From $g $d 718# delimiter (operator) characters 719D\&o\&.:%@!^ 720 721### format of headers: 722H\&Date: $a 723H\&From: $g$?x ($x)$. 724H\&Full-Name: $x 725H\&Message-Id: <$t.$p.$B@$A> 726H\&Posted-Date: $a 727 728### name classifications 729# arpanet hostnames 730C\&A\&ucb berkeley 731# list of local host names 732C\&B\&j IngVax 733# berknet hosts on the arpanet 734C\&C\&i ingres ing70 735# uucp hostnames 736C\&U\&ucbvax ernie 737 738### mailers 739# local mail -- must be zero 740M\&local /bin/mail rlsAmn $f ...local\&mail -d $u 741# program mail -- must be one 742M\&prog /bin/csh lA $f ...prog\&mail -fc $u 743# berkeley net mail 744M\&berk /usr/net/bin/sendberkmail fxs $B:$f ...berk\&mail -m $h -h $c -t $u 745# arpanet mail 746M\&arpa /usr/lib/mailers/arpa sAu $f@$A ...arpa\&mail $f $h $u 747# uucp mail 748M\&uucp /usr/bin/uux rsDxm $U!$f ...uucp\&mail - $h!rmail ($u) 749 750### rewriting rules 751R\&$-h.$+u $+h:$+u change "." to ":" 752R\&$=C:$+u@$-h $+u@$+h delete ing70: on arpanet addresses 753R\&$+u@$=A ing70:$+u delete local arpa hosts 754R\&$+u@$-h $#berk$@ing70$:$+u@$+h send arpa mail to ing70 755R\&$+h^$+u $+h!$+u change "^" to "!" 756R\&$-x!$=U!$+y csvax:$+y delete uucp loops through csvax 757R\&$-h!$+u csvax:$+h!$+u send uucp mail to csvax 758R\&$-x:$-h:$+u $+h:$+u delete multiple berk hosts 759R\&$=B:$+u $+u delete local berk hosts 760R\&$-h:$+u $#berk$@$+h$:$+u resolve berk mail 761R\&$+u $#local$:$+u resolve local mail 762 763### rewriting rules for from host 764S\&1 765R\&ing70:$+u@$-h $+u@$+h arpanet mail is automatic 766R\&CSVAX:$-h!$+u $+h!$+u uucp mail is automatic 767 768 769.ce 770Figure 2. Sample configuration file. 771.)z 772.sh 3 "D \*- define macro" 773.pp 774This line defines a macro. 775Macros have single character names. 776They can be interpolated using the escape 777.b $\c 778.i x , 779where 780.i x 781is the macro name. 782By convention, 783all upper-case letters are unused by 784.i sendmail 785and may be used freely by the user; 786all other names are reserved for use by sendmail. 787Certain macros 788.i must 789be defined, 790and are used internally. 791These are: 792.(b 793$l UNIX-style \*(lqFrom\*(rq line. 794$n My address in error messages. 795$o \*(lqOperators\*(rq in addresses. 796.)b 797The 798.b $l 799macro is expanded when 800.i sendmail 801wants to insert a UNIX-style 802.q From 803line on messages. 804This typically expands to something like: 805.(b 806From joe Wed Aug 12 09:15:13 1981 807.)b 808The 809.b $n 810macro is used as the name of this process 811when error messages are being mailed back. 812Typically, 813it is wise to include an alias 814so that mail to this address will be sent to root. 815The 816.b $o 817macro defines the characters 818that will separate words when addresses are being broken up. 819Each of these becomes a word by itself when scanned. 820Blanks and tabs are built-in separators 821but are ignored, 822i.e., are not turned into words. 823For example, the input: 824.(b 825Ing70:ZRM @ MIT-MC SRI-KL 826.)b 827Is broken up into the six words: 828.(b 829Ing70, :, ZRM, @, MIT-MC, SRI-KL 830.)b 831assuming that colon and at-sign are operators 832(but hyphen is not). 833.pp 834A number of macros are defined by 835.i sendmail 836for use as primitives. 837These are: 838.(l 839$a The date in ARPANET format. 840$c The hop count. 841$d The date in UNIX (ctime) format. 842$f The sender's (from) address. 843$g The sender's address translated by the mailer. 844$h The host of the recipient. 845$p The process id of sendmail in decimal. 846$t The time in seconds in decimal. 847$u The user part of the recipient. 848$v The version number of sendmail. 849$x The full name of the sender. 850$y The id of the sender's terminal. 851$z The home directory of the recipient. 852.)l 853.pp 854The 855.b $p 856and 857.b $t 858macros are used to create unique strings. 859The 860.b $f 861macro is the id of the sender 862as originally determined; 863when mailing to a specific person, 864the 865.b $g 866macro is the address of the sender 867with respect to the receiver. 868For example, 869if I send to 870.q csvax:samwise 871the 872.b $f 873and 874.b $g 875macros are: 876.(b 877$f eric 878$g IngVAX:eric 879.)b 880This only applies to the first step in the link. 881For example, 882sending to Ing70:drb@bbn-unix, 883we have 884.b $f 885and 886.b $g 887as above for the transfer to Ing70, but: 888.(b 889$f IngVAX:eric 890$g IngVAX:eric@Berkeley 891.)b 892For transfer to the ARPANET. 893When sending, the 894.b $u , 895.b $h , 896and 897.b $z 898macros get set to the user, host, and home directory 899(respectively) 900of the receiver. 901The host is only set if the user is not local, 902and the home directory is only set if the user is local. 903.pp 904A primitive conditional is available during macro expansion. 905The construct: 906.(b 907$?x text1 $: text2 $. 908.)b 909tests if macro 910.b $\c 911.i x 912is defined. 913If it is, 914text1 is interpolated; 915otherwise, 916text2 is interpolated. 917.sh 3 "H \*- define header" 918.pp 919The remainder of the 920.b H 921line looks like a regular header line, 922except that the field value is macro expanded 923before use. 924All headers mentioned in this way 925are automatically inserted 926into every message 927except for headers mentioned in the compile-time 928configuration file 929.i conf.c . 930These headers are 931Date, 932From, 933Full-Name, 934Message-Id, 935and 936Received-Date. 937To get these fields the appropriate flag 938must be specified 939for the receiving mailer. 940.pp 941Since the file 942.q ".mailcf" 943in the sender's home directory is read and processed, 944it is possible to add customized header lines. 945For example, 946the .mailcf consisting of: 947.(b 948H\&Phone: (415) 642-7520 949.)b 950will add that line to every outgoing message. 951.sh 3 "M \*- define mailer" 952.pp 953This line is structured into fields 954separated by white space (spaces or tabs). 955The fields are: 956.np 957The internal name of the mailer, 958referred to in the rewriting rules. 959.np 960The pathname of the program to execute for this mailer. 961.np 962The flags for this mailer, 963described below. 964.np 965The macro string to become the 966.b $g 967macro (translated sender) 968for this mailer. 969.np 970The argument vector passed to the mailer 971(macro expanded). 972.pp 973The flags are a series of characters: 974.ls 1 975.ip f 976The mailer wants a 977.b \-f 978.i from 979flag, 980but only if this is a network forward operation 981(i.e., 982the mailer will give an error 983if the executing user does not have special permissions). 984.ip r 985Same as 986.b f , 987but sends a 988.b \-r 989flag. 990.ip q 991Don't print errors \*- the mailer will do it for us. 992.ip S 993Don't reset your userid before calling the mailer. 994This would be used in a secure environment where 995.i sendmail 996ran as a special user. 997This could be used to prevent 998(or at least complicate) 999forged addresses. 1000.ip n 1001This mailer does not want a UNIX-style 1002.q From 1003line on the message. 1004.ip l 1005This mailer is local, 1006so no host will be specified. 1007.ip s 1008Strip quote characters off of addresses 1009before calling the mailer. 1010.ip m 1011This mailer can send to multiple users 1012(on the same host) 1013in one call. 1014.ip F 1015This mailer wants a 1016.q From: 1017header line. 1018.ip D 1019This mailer wants a 1020.q Date: 1021header line. 1022.ip M 1023This mailer wants a 1024.q Message-Id: 1025header line. 1026.ip x 1027This mailer wants a 1028.q Full-Name: 1029header line. 1030.ip u 1031Upper case should be preserved in user names. 1032.ip h 1033Upper case should be preserved in host names. 1034.ip A 1035This mailer wants an ARPANET standard header 1036(equivalent to the 1037.b F 1038and 1039.b D 1040flags). 1041.ls 1042.sh 3 "S \*- use rewriting set" 1043.pp 1044There are two sets of rewriting rules. 1045Set zero is used to rewrite recipient addresses. 1046Set one is used to rewrite sender addresses. 1047Set one can be used to eliminate implicit links. 1048For example, 1049if there exists a site on on the BerkNet called 1050.q Ing70 1051which is an ARPANET gateway, 1052and we are on a site called 1053.q IngVAX , 1054ARPANET mail coming into 1055.q Ing70 1056for someone on 1057.q IngVAX 1058will read: 1059.(b 1060From: Ing70:auser@ahost 1061.)b 1062Rewriting set one can rewrite this as: 1063.(b 1064From: auser@ahost 1065.)b 1066since 1067.q Ing70 1068will be implied. 1069.pp 1070When you change to a new set, 1071the previous content of that set is cleared. 1072.sh 3 "R \*- rewriting rule" 1073.pp 1074The heart of parsing is the rewriting rules. 1075The process is essentially textual. 1076First, 1077the address to be rewritten is broken up into words. 1078Words are defined as strings of non-special characters 1079separated by white space or single special characters 1080as defined by the 1081.b $o 1082macro. 1083Then, 1084the words are rewritten using simple pattern matching. 1085Words in the pattern match themselves 1086unless they begin with dollar sign. 1087The dollar escapes have the following meanings\**: 1088.(f 1089\**These dollar escapes have nothing to do with macro expansion. 1090.)f 1091.(b 1092$-x Match a single word (and call it x). 1093$+x Match one or more words (and call them x). 1094$=c Match any word in class c (see below). 1095.)b 1096The case of letters is ignored in pattern matching 1097(including class comparisons). 1098.pp 1099When a pattern (also called a left hand side or LHS) 1100matches, 1101the input is rewritten as defined by the right hand side (RHS). 1102Acceptable escapes in the RHS are: 1103.(b 1104$+x Replace from corresponding match in LHS. 1105$#word Canonical mailer name. 1106$@word Canonical host name. 1107$:word Canonical user name. 1108.)b 1109Patterns are reexecuted until it either resolves to 1110a canonical name 1111(i.e., 1112.q "$#mailer$@host$:user" ) 1113or fails. 1114As soon as the input resolves to a canonical name, 1115matching ends; 1116otherwise, 1117the next pattern is tried. 1118The 1119.q "$@host" 1120part is not needed 1121if the mailer does not require a host. 1122The special mailer 1123.q error 1124causes the user part to be printed as an error. 1125.sh 3 "C \*- define word class" 1126.pp 1127There are twenty six word classes, 1128represented as 1129.q A 1130through 1131.q Z . 1132For example: 1133.(b 1134CVcsvax ingvax esvax 1135.)b 1136defines the words 1137.q csvax , 1138.q ingvax , 1139and 1140.q esvax 1141to all be in class 1142.q V , 1143so that 1144.q $=V 1145on the LHS of a rewriting rule 1146will match any of these words. 1147.sh 2 "A Detailed Example" 1148.pp 1149We will now follow the configuration file 1150in figure 2 1151through in detail. 1152.sh 3 "Macro definitions" 1153.(b 1154DABerkeley 1155DBIngVAX 1156DUucbvax 1157DnMAILER-DAEMON 1158DlFrom $g $d 1159Do.:%@!^ 1160.)b 1161The first three macros are for convenience only, 1162and are used to define the local host names 1163on the ARPANET, BerkNet, and the UUCP net 1164respectively. 1165.pp 1166Macro 1167.b n 1168defines the name of this entity 1169when error messages are sent. 1170Macro 1171.b l 1172defines what the first line 1173of a message in UNIX format looks like, 1174in this case the version 7 standard of: 1175.(b 1176From sender-name time-of-submission 1177.)b 1178The 1179.b o 1180macro 1181tells what characters will be distinct from names 1182when scanning addresses. 1183In this case, 1184dot and colon will be used 1185to distinguish BerkNet addresses, 1186at sign for ARPANET addresses, 1187and exclamation point and caret for UUCP addresses. 1188.sh 3 "Header definitions" 1189.(b 1190H\&Date: $a 1191H\&From: $g$?x ($x)$. 1192H\&Full-Name: $x 1193H\&Message-Id: <$t.$p.$B@$A> 1194H\&Posted-Date: $a 1195.)b 1196These define the headers 1197that may be added to a message. 1198The 1199.q Date: 1200is just the ARPANET idea of the date. 1201The 1202.q From: 1203line is the translated version of the sender, 1204followed by the sender's full name if known. 1205The 1206.q Message-Id: 1207field has the time and process id's concatenated 1208with the BerkNet and ARPANET addresses 1209to make a unique string. 1210Finally, the 1211.q Posted-Date: 1212is the date in ARPANET format; 1213it differs from 1214.q Date: 1215in that it is always output as soon as the message is submitted, 1216and hence indicates the time that the message first enters 1217the mail delivery system [4]. 1218.(d 1219[4] NBS standard 1220.)d 1221.sh 3 "Name classifications" 1222.(b 1223C\&A\&ucb berkeley 1224C\&B\&j IngVax 1225C\&C\&i ingres ing70 1226C\&U\&ucbvax ernie 1227.)b 1228These commands put the words 1229.q ucb 1230and 1231.q berkeley 1232into class 1233.q A , 1234the valid names of this site on the ARPANET. 1235Words 1236.q j 1237and 1238.q ingvax 1239are in class 1240.q B , 1241the local names on BerkNet. 1242Class 1243.q C , 1244the names of the site which has the ARPANET link, 1245has the words 1246.q i , 1247.q ingres , 1248and 1249.q ing70 . 1250Finally, 1251.q ucbvax 1252and 1253.q ernie 1254are the UUCP names of our UUCP gateway, 1255and are in class 1256.q U . 1257.pp 1258The classes will be used in the patterns of the rewriting rules 1259as described below. 1260.sh 3 "Mailer definitions" 1261.(b 1262M\&local /bin/mail rlsAmn $f ...localmail -d $u 1263M\&prog /bin/csh lA $f ...progmail -fc $u 1264M\&berk /usr/net/bin/sendberkmail fxs $B:$f ...berkmail -m $h -h $c -t $u 1265M\&arpa /usr/lib/mailers/arpa sAu $f@$A ...arpamail $f $h $u 1266M\&uucp /usr/bin/uux rsDxm $U!$f ...uucpmail - $h!rmail ($u) 1267.)b 1268Five mailers are known in the configuration file. 1269The first two 1270.i must 1271be declared as 1272.b local 1273and 1274.b prog 1275and must come as the first and second mailers respectively. 1276.pp 1277Local mail is sent using 1278/bin/mail. 1279It takes a 1280.b \-r 1281flag, 1282is local, 1283quote characters are stripped before sending, 1284takes ARPANET standard headers, 1285can deliver to multiple recipients at once, 1286and does not want a UNIX-style 1287.q From 1288line since it will add one itself. 1289The translated from address is the same as the raw from address, 1290since no network hops are made. 1291The argument vector has a program name, 1292a 1293.b \-d 1294flag (\c 1295.q "really deliver" , 1296which must be added to /bin/mail), 1297and the list of recipients \*- one recipient per argument. 1298.pp 1299Mail piped through programs 1300is interpreted by /bin/csh. 1301It does not take a 1302.b \-r 1303flag, 1304quotes should be left, 1305it can only deal with one user, 1306and it does want a UNIX-style 1307.q From 1308line, 1309but is still local and still wants an ARPANET style header. 1310.pp 1311BerkNet mail is processed by 1312/usr/net/bin/sendberkmail. 1313It takes a 1314.b \-f 1315flag, 1316wants a 1317.q Full-Name: 1318header line, 1319and wants quotes stripped. 1320The 1321.q Full-Name: 1322is used here because if it were given as a comment 1323in a 1324.q From: 1325line it might be discarded by later instantiations of 1326.i sendmail . 1327The from address as seen by the receiver is 1328.q IngVAX:sender , 1329and it takes a flag-oriented 1330rather than a positional 1331command list. 1332.pp 1333The ARPANET wants quotes stripped, 1334ARPANET standard headers, 1335and wants the user name left with case intact. 1336It takes a positional command list. 1337.pp 1338UUCP mail calls 1339.i uux 1340with a 1341.b \-r 1342flag, 1343quotes stripped, 1344a 1345.q Date: 1346line, 1347a 1348.q Full-Name: 1349line, 1350and with multiple users listed. 1351.sh 3 "Rewriting rules for recipient addresses" 1352.(b 1353R\&$-h.$+u $+h:$+u change "." to ":" 1354R\&$=C:$+u@$-h $+u@$+h delete ing70: on arpanet addresses 1355R\&$+u@$=A ing70:$+u delete local arpa hosts 1356R\&$+u@$-h $#berk$@ing70$:$+u@$+h send arpa mail to ing70 1357R\&$+h^$+u $+h!$+u change "^" to "!" 1358R\&$-x!$=U!$+y csvax:$+y delete uucp loops through csvax 1359R\&$-h!$+u csvax:$+h!$+u send uucp mail to csvax 1360R\&$-x:$-h:$+u $+h:$+u delete multiple berk hosts 1361R\&$=B:$+u $+u delete local berk hosts 1362R\&$-h:$+u $#berk$@$+h$:$+u resolve berk mail 1363R\&$+u $#local$:$+u resolve local mail 1364.)b 1365Dots in addresses are translated to colons 1366in the first rule. 1367Redundant explicit routing to the ARPANET is deleted 1368in the second rule. 1369Hops out over the ARPANET 1370back to us are deleted in the third rule \*- 1371note that the host that we would have come in on 1372is inserted. 1373Real ARPANET mail is resolved immediately with no further ado \*- 1374it is sent out over the BerkNet to the ing70, 1375and further rewriting stops immediately. 1376.pp 1377Carets are changed to exclamation points 1378for UUCP addresses in the fifth rule. 1379The sixth rule deletes loops out into UUCP land 1380and back to us \*- noting that we will be left on CSVAX. 1381Multiple BerkNet hosts are deleted in rule seven \*- 1382this can occur internally quite easily 1383as a side effect of a rewriting rule. 1384Rule eight deletes local BerkNet hosts. 1385The last two rules resolve BerkNet and local mail. 1386.pp 1387Consider the following examples: 1388.(b 1389 esvax.asa 1390[1] esvax:asa 1391[10] $#berk$@esvax$:asa 1392.)b 1393.(b 1394 research^vax135^dmr 1395[5] research!vax135^dmr 1396[5] research!vax135!dmr 1397[7] $#berk$@csvax$:research!vax135!dmr 1398.)b 1399.(b 1400 research!ucbvax!j:eric 1401[6] csvax:j:eric 1402[8] j:eric 1403[9] eric 1404[11] $#local$:eric 1405.)b 1406.(b 1407 ing70:wnj@Berkeley 1408[2] wnj@Berkeley 1409[3] ing70:wnj 1410[10] $#berk$@ing70$:wnj 1411.)b 1412.sh 3 "Rewriting rules for sender addresses" 1413.(b 1414S\&1 1415R\&ing70:$+u@$-h $+u@$+h arpanet mail is automatic 1416R\&CSVAX:$-h!$+u $+h!$+u uucp mail is automatic 1417.)b 1418The 1419.b S 1420line starts putting the rules into set one. 1421These rules strip off the 1422.q ing70: 1423from incoming ARPANET mail 1424and the 1425.q CSVAX: 1426off of incoming UUCP mail. 1427.sh 1 "COMPARISON WITH OTHER MAILERS" 1428.sh 2 "Delivermail" 1429.pp 1430.i Sendmail 1431is an outgrowth of 1432.i delivermail . 1433The primary differences are: 1434.np 1435Configuration information is not compiled in. 1436This simplifies many of the problems 1437of moving to other machines. 1438It also allows easy debugging of new mailers. 1439.np 1440Address parsing is more flexible. 1441For example, 1442.i delivermail 1443only supported one gateway to any network, 1444whereas 1445.i sendmail 1446can be sensitive to host names 1447and reroute to different gateways. 1448.np 1449Forwarding and 1450:include: 1451support eliminate the requirement that the system alias file 1452be writable by any user 1453(or that an update program be written, 1454or that the system administration make all changes). 1455.np 1456.i Sendmail 1457supports message batching across networks 1458when a message is being sent to multiple recipients. 1459.sh 2 "MMDF" 1460.pp 1461MMDF [ref] 1462spans a much wider problem set than 1463.i sendmail . 1464For example, 1465MMDF includes a 1466.q "phone network" 1467mailer, whereas 1468.i sendmail 1469calls on preexisting mailers in most cases. 1470.i Sendmail 1471is approximately equivalent to the 1472SUBMIT and DELIVER phases of MMDF. 1473Because of this difference in design goals, 1474some of the important features of MMDF 1475(queueing, retransmission, and two-phase timeout) 1476are unimplemented by 1477.i sendmail . 1478.pp 1479MMDF and 1480.i sendmail 1481both support aliasing, 1482customized mailers, 1483message batching, 1484and automatic forwarding to gateways. 1485.sh 2 "Message Processing Module" 1486.pp 1487The Message Processing Module (MPM) 1488discussed by Postel [ref] 1489matches 1490.i sendmail 1491closely in terms of its basic architecture. 1492However, 1493like MMDF, 1494the MPM includes the network interface software 1495as part of its domain. 1496.pp 1497MPM also postulates a duplex channel to the receiver, 1498as does MMDF. 1499This allows simpler handling of errors 1500by the mailer 1501than possible in 1502.i sendmail ; 1503when a message queued by 1504.i sendmail 1505is sent, 1506any errors must be returned to the sender 1507by the mailer itself. 1508Both MPM and MMDF mailers 1509can return an immediate error response, 1510and a single error processor can create an appropriate response. 1511.pp 1512MPM prefers passing the message as a structured message, 1513with type-length-value tuples. 1514This implies a much higher degree of cooperation 1515between mailers than required by 1516.i sendmail . 1517MPM also assumes a universally agreed upon internet name space 1518(with each address a net-host-user tuple), 1519which 1520.i sendmail 1521does not. 1522.sh 1 "EVALUATIONS AND FUTURE PLANS" 1523.pp 1524.i Sendmail 1525is designed to work in a nonhomogeneous environment. 1526Every attempt is made to avoid imposing any constraints 1527on the underlying mailers. 1528This goal has driven much of the design. 1529One of the major problems 1530has been the lack of a uniform address space, 1531as postulated in [IP] 1532.(d 1533[IP] -- internet protocol 1534.)d 1535and [PostelIMS]. 1536.(d 1537[PostelIMS] -- Internet Message Structure 1538.)d 1539.pp 1540A nonuniform address space implies that path will be specified 1541in all addresses, 1542either explicitly (as part of the address) 1543or implicitly 1544(as with implied forwarding to gateways). 1545This has the unpleasant effect of making replying to messages 1546exceedingly difficult, 1547since there is no one 1548.q address 1549for any person, 1550but only a way to get there from wherever you are. 1551.pp 1552Interfacing to mail programs 1553that were not initially intended to be applied 1554in an internet environment 1555has been amazingly successful, 1556and has reduced the job to a manageable task. 1557.pp 1558However, 1559many of these mailers implement their own queueing and retransmission. 1560In networks that support store-and-forward file transfer, 1561such as BerkNet and UUCP, 1562this feature must be supplied already. 1563However, 1564networks that transfer in real time, 1565such as the ARPANET or an Ether-based network 1566[ref], 1567generally do not provide these features. 1568Also, 1569networks which provide these generally do not understand 1570timeouts or returning the text of the message on error, 1571both highly desirable features\**. 1572.(f 1573\**We have implemented an ARPANET mailer which 1574returns the message on error and does one-stage timeout 1575(returning the message after three days). 1576.)f 1577Such queueing, retransmission, and two-phase timeout 1578may be integrated into 1579.i sendmail 1580if it seems desirable. 1581.pp 1582.i Sendmail 1583has knowledge of a few difficult environments 1584built in. 1585It generates ARPANET FTP compatible error messages 1586(prepended with three-digit numbers 1587[FTP1, FTP2]) 1588.(d 1589[FTP1] -- FTP description 1590.)d 1591.(d 1592[FTP2] -- revised FTP codes 1593.)d 1594as necessary, 1595optionally generates UNIX-style 1596.q From 1597lines on the front of messages for some mailers, 1598and knows how to parse the same lines on input. 1599Although it still adds and understands ARPANET-style 1600.q From: 1601lines, 1602this can be inconvenient to sites which have abandoned UNIX mail. 1603Also, 1604error handling has an option customized for BerkNet. 1605.pp 1606One surprisingly major annoyance in most internet mailers 1607(such as MMDF) 1608is that the location and format of local mail is built in\**. 1609.(f 1610\**For example, 1611MMDF puts local mail in the file 1612.q .mail 1613\*- useful if you are running version 6. 1614.)f 1615.i Sendmail 1616eliminates all knowledge of location 1617and can function successfully with different formats. 1618.pp 1619The ability to automatically generate a response to incoming mail 1620(by forwarding mail to a program) 1621seems useful 1622(\c 1623.q "I am on vacation until late August...." ) 1624but can create problems 1625such as forwarding loops 1626(two people on vacation whose programs send notes back and forth, 1627for instance) 1628if these programs are not well written. 1629It might be desirable to implement some form of load limiting. 1630I am unaware of any mail system that addresses this problem. 1631.pp 1632.i Sendmail 1633should be modified to run as a daemon, 1634reading an MPX file 1635(or other IPC scheme) 1636to receive mail and process it. 1637This would reduce the cost of sending mail to writing the message 1638into a known file. 1639.i Sendmail 1640would be modified to have a very different argument structure. 1641It already has an option to read the recipients 1642from the message header. 1643A more palatable technique for giving error messages 1644would also have to be devised. 1645.pp 1646The configuration file is currently practically inscrutable; 1647considerable convenience could be realized 1648with a higher-level format. 1649For example, a description might read: 1650.(b 1651(MACRO name value) 1652(HEADER name value 1653 (OPTION option) ... 1654 (NEEDS option) ... ) 1655(MAILER name path xlatstring 1656 (OPTION option) ... 1657 (ARGV arg ... )) 1658(CLASS name word ...) 1659(REWRITE setname 1660 (RULE lhs rhs) ... ) 1661.)b 1662.pp 1663Many other nice features could be implemented. 1664For example, 1665if we were sure that the alias file were writable by the effective user 1666(i.e., if 1667.i sendmail 1668were to run setuid) 1669then the inverted form could be rebuilt automatically when the 1670text copy was changed. 1671However, this appears to be little more than frosting. 1672.sp 2i 1673.pd 1674