151222Sericdivert(-1) 251222Seric# 351222Seric# Copyright (c) 1983 Eric P. Allman 451222Seric# Copyright (c) 1988 The Regents of the University of California. 551222Seric# All rights reserved. 651222Seric# 751222Seric# %sccs.include.redist.sh% 851222Seric# 951222Sericdivert(0) 1051222Seric 11*57944SericVERSIONID(`@(#)proto.m4 6.3 (Berkeley) 02/12/93') 1251222Seric 1351322SericMAILER(local)dnl 1451222Seric 1552646Sericifdef(`_OLD_SENDMAIL_', `dnl', 1652646Seric`# level 3 config file format 1752646SericV3') 1852646Seric 1951222Seric################## 2051222Seric# local info # 2151222Seric################## 2251222Seric 2351889SericCwlocalhost 2451887Sericifdef(`USE_CW_FILE', 2551889Seric`# file containing names of hosts for which we receive email 2651222SericFw/etc/sendmail.cw', `dnl') 2751222Seric 2851222Sericifdef(`UUCP_RELAY', 2951222Seric`# UUCP relay host 3051281SericCONCAT(DY, UUCP_RELAY) 31*57944Seric 3251222Seric')dnl 3351222Sericifdef(`BITNET_RELAY', 3451222Seric`# BITNET relay host 3551222SericCONCAT(DB, BITNET_RELAY) 36*57944Seric 3751222Seric')dnl 3851222Sericifdef(`CSNET_RELAY', 3951222Seric`# CSNET relay host 4051222SericCONCAT(DC, CSNET_RELAY) 41*57944Seric 4251222Seric')dnl 4351222Seric# my official hostname ($w or $w.$D) 4451291SericCONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D)) 4551222Seric 4651222Seric# who I masquerade as (can be $j) 4751222SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)) 4851222Seric 4951222Seric# who I send unqualified names to (null means deliver locally) 5051222SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY)) 5151222Seric 5257527Seric# who gets all local email traffic ($R has precedence for unqualified names) 5357527SericCONCAT(DH, ifdef(`MAIL_HUB', MAIL_HUB)) 5457527Seric 5557245Seric# class L: names that should be delivered locally, even if we have a relay 5657245Seric# class E: names that should be exposed as from this host, even if we masquerade 5751279SericCLroot 5857245SericCEroot 5951279Sericundivert(5)dnl 6051279Seric 6151222Seric# operators that cannot be in local usernames (i.e., network indicators) 6251222SericCO @ % ! 6351222Seric 6451322Seric# a class with just dot (for identifying canonical names) 6551322SericC.. 6651322Seric 67*57944Seric 68*57944Seric###################### 69*57944Seric# Special macros # 70*57944Seric###################### 71*57944Seric 72*57944Seric# SMTP initial login message 73*57944SericCONCAT(De, confSMTP_LOGIN_MSG) 74*57944Seric 75*57944Seric# UNIX initial From header format 76*57944SericCONCAT(Dl, confFROM_LINE) 77*57944Seric 78*57944Seric# my name for error messages 79*57944SericCONCAT(Dn, confMAILER_NAME) 80*57944Seric 81*57944Seric# delimiter (operator) characters 82*57944SericCONCAT(Do, confOPERATORS) 83*57944Seric 84*57944Seric# format of a total name 85*57944SericCONCAT(Dq, ifdef(`confFROM_HEADER', confFROM_HEADER, 86*57944Seric ifdef(`_OLD_SENDMAIL_', `$g$?x ($x)$.', `$?x$x <$g>$|$g$.'))) 87*57944Sericinclude(`../m4/version.m4') 88*57944Seric 89*57944Seric############### 90*57944Seric# Options # 91*57944Seric############### 92*57944Seric 93*57944Seric# preserve 8 bits on message body on input? 94*57944SericCONCAT(O8, confEIGHT_BIT_INPUT) 95*57944Seric 96*57944Seric# wait (in minutes) for alias file rebuild 97*57944SericCONCAT(Oa, confALIAS_WAIT) 98*57944Seric 99*57944Seric# location of alias file 100*57944SericCONCAT(OA, ifdef(`ALIAS_FILE', ALIAS_FILE, /etc/aliases)) 101*57944Seric 102*57944Seric# substitution for space (blank) characters 103*57944SericCONCAT(OB, confBLANK_SUB) 104*57944Seric 105*57944Seric# connect to "expensive" mailers on initial submission? 106*57944SericCONCAT(Oc, confCON_EXPENSIVE) 107*57944Seric 108*57944Seric# checkpoint queue runs after every N successful deliveries 109*57944SericCONCAT(OC, confCHECKPOINT_INTERVAL) 110*57944Seric 111*57944Seric# default delivery mode 112*57944SericCONCAT(Od, confDELIVERY_MODE) 113*57944Seric 114*57944Seric# automatically rebuild the alias database? 115*57944SericCONCAT(OD, confAUTO_REBUILD) 116*57944Seric 117*57944Seric# error message header/file */ 118*57944Sericifdef(`confERROR_MESSAGE', 119*57944Seric concat(OE, confERROR_MESSAGE), 120*57944Seric #OE/etc/sendmail.oE) 121*57944Seric 122*57944Seric# error mode 123*57944Sericifdef(`confERROR_MODE', 124*57944Seric concat(Oe, confERROR_MODE), 125*57944Seric #Oep) 126*57944Seric 127*57944Seric# save Unix-style "From_" lines at top of header? 128*57944SericCONCAT(Of, confSAVE_FROM_LINES) 129*57944Seric 130*57944Seric# temporary file mode 131*57944SericCONCAT(OF, confTEMP_FILE_MODE) 132*57944Seric 133*57944Seric# match recipients against GECOS field? 134*57944SericCONCAT(OG, confMATCH_GECOS) 135*57944Seric 136*57944Seric# default GID 137*57944SericCONCAT(Og, confDEF_GROUP_ID) 138*57944Seric 139*57944Seric# maximum hop count 140*57944SericCONCAT(Oh, confMAX_HOP) 141*57944Seric 142*57944Seric# location of help file 143*57944SericCONCAT(OH, ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf)) 144*57944Seric 145*57944Seric# ignore dots as terminators in incoming messages? 146*57944SericCONCAT(Oi, confIGNORE_DOTS) 147*57944Seric 148*57944Seric# Insist that the BIND name server be running to resolve names 149*57944Sericifdef(`confBIND_OPTS', 150*57944Seric CONCAT(OI, confBIND_OPTS), 151*57944Seric #OI) 152*57944Seric 153*57944Seric# Forward file search path 154*57944Sericifdef(`confFORWARD_PATH', 155*57944Seric CONCAT(OJ, confFORWARD_PATH), 156*57944Seric #OJ/var/forward/$u:$z/.forward.$w:$z/.forward) 157*57944Seric 158*57944Seric# open connection cache size 159*57944SericCONCAT(Ok, confMCI_CACHE_SIZE) 160*57944Seric 161*57944Seric# open connection cache timeout 162*57944SericCONCAT(OK, confMCI_CACHE_TIMEOUT) 163*57944Seric 164*57944Seric# log level 165*57944SericCONCAT(OL, confLOG_LEVEL) 166*57944Seric 167*57944Seric# send to me too, even in an alias expansion? 168*57944SericCONCAT(Om, confME_TOO) 169*57944Seric 170*57944Seric# verify RHS in newaliases? 171*57944SericCONCAT(On, confCHECK_ALIASES) 172*57944Seric 173*57944Seric# default messages to old style headers if no special punctuation? 174*57944SericCONCAT(Oo, confOLD_STYLE_HEADERS) 175*57944Seric 176*57944Seric# who (if anyone) should get extra copies of error messages 177*57944Sericifdef(`confCOPY_ERRORS_TO', 178*57944Seric CONCAT(OP, confCOPY_ERRORS_TO), 179*57944Seric #OPPostmaster) 180*57944Seric 181*57944Seric# slope of queue-only function 182*57944Sericifdef(`confQUEUE_FACTOR', 183*57944Seric CONCAT(Oq, confQUEUE_FACTOR), 184*57944Seric #Oq600000) 185*57944Seric 186*57944Seric# queue directory 187*57944SericCONCAT(OQ, ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue)) 188*57944Seric 189*57944Seric# read timeout -- now OK per RFC 1123 section 5.3.2 190*57944SericCONCAT(Or, confREAD_TIMEOUT) 191*57944Seric 192*57944Seric# queue up everything before forking? 193*57944SericCONCAT(Os, confSAFE_QUEUE) 194*57944Seric 195*57944Seric# status file 196*57944SericCONCAT(OS, ifdef(`STATUS_FILE', STATUS_FILE, /etc/sendmail.st)) 197*57944Seric 198*57944Seric# default message timeout interval 199*57944SericCONCAT(OT, confMESSAGE_TIMEOUT) 200*57944Seric 201*57944Seric# time zone handling: 202*57944Seric# if undefined, use system default 203*57944Seric# if defined but null, use TZ envariable passed in 204*57944Seric# if defined and non-null, use that info 205*57944Sericifelse(confTIME_ZONE, `USE_SYSTEM', `#Ot', 206*57944Seric confTIME_ZONE, `USE_TZ', `', 207*57944Seric `CONCAT(Ot, confTIME_ZONE)') 208*57944Seric 209*57944Seric# default UID 210*57944SericCONCAT(Ou, confDEF_USER_ID) 211*57944Seric 21251887Seric# list of locations of user database file (null means no lookup) 213*57944SericCONCAT(OU, ifdef(`USERDB_SPEC', `USERDB_SPEC')) 21451222Seric 215*57944Seric# can we guarantee no wildcard MX records matching our domain? 216*57944SericCONCAT(Ow, confNO_WILDCARD_MX) 21751222Seric 218*57944Seric# load average at which we just queue messages 219*57944SericCONCAT(Ox, confQUEUE_LA) 220*57944Seric 221*57944Seric# load average at which we refuse connections 222*57944SericCONCAT(OX, confREFUSE_LA) 223*57944Seric 224*57944Seric# work recipient factor 225*57944Sericifdef(`confWORK_RECIPIENT_FACTOR', 226*57944Seric CONCAT(Oy, confWORK_RECIPIENT_FACTOR), 227*57944Seric #Oy30000) 228*57944Seric 229*57944Seric# deliver each queued job in a separate process? 230*57944SericCONCAT(OY, confSEPARATE_PROC) 231*57944Seric 232*57944Seric# work class factor 233*57944Sericifdef(`confWORK_CLASS_FACTOR', 234*57944Seric CONCAT(Oz, confWORK_CLASS_FACTOR), 235*57944Seric #Oz1800) 236*57944Seric 237*57944Seric# work time factor 238*57944Sericifdef(`confWORK_TIME_FACTOR', 239*57944Seric CONCAT(OZ, confWORK_TIME_FACTOR), 240*57944Seric #OZ90000) 241*57944Seric 242*57944Seric########################### 243*57944Seric# Message precedences # 244*57944Seric########################### 245*57944Seric 246*57944SericPfirst-class=0 247*57944SericPspecial-delivery=100 248*57944SericPbulk=-60 249*57944SericPjunk=-100 250*57944Seric 251*57944Seric##################### 252*57944Seric# Trusted users # 253*57944Seric##################### 254*57944Seric 255*57944SericTroot 256*57944SericTdaemon 257*57944SericTuucp 258*57944Seric 259*57944Seric######################### 260*57944Seric# Format of headers # 261*57944Seric######################### 262*57944Seric 263*57944SericH?P?Return-Path: <$?<$<$|$g$.> 264*57944SericHReceived: $?sfrom $s $.by $j ($v/$Z) id $i; $b 265*57944SericH?D?Resent-Date: $a 266*57944SericH?D?Date: $a 267*57944SericH?F?Resent-From: $q 268*57944SericH?F?From: $q 269*57944SericH?x?Full-Name: $x 270*57944SericHSubject: 271*57944Seric# HPosted-Date: $a 272*57944Seric# H?l?Received-Date: $b 273*57944SericH?M?Resent-Message-Id: <$t.$i@$j> 274*57944SericH?M?Message-Id: <$t.$i@$j> 27556786Sericundivert(6)dnl 27651222Seric# 27751222Seric###################################################################### 27851222Seric###################################################################### 27951222Seric##### 28051222Seric##### REWRITING RULES 28151222Seric##### 28251222Seric###################################################################### 28351222Seric###################################################################### 28451222Seric 28551222Seric 28651222Seric########################################### 28751222Seric### Rulset 3 -- Name Canonicalization ### 28851222Seric########################################### 28951260SericS3 29051222Seric 29151222Seric# handle "from:<>" special case 29255416SericR$* < > $* $@ @ turn into magic token 29351222Seric 29451222Seric# basic textual canonicalization -- note RFC733 heuristic here 29557012SericR$*<$*>$*<$*>$* <$2>$3$4$5 strip multiple <> <> 29651222SericR$*<$*<$*<$+>$*>$*>$* $4 3-level <> nesting 29751222SericR$*<$*<$+>$*>$* $3 2-level <> nesting 29851222SericR$*<$+>$* $2 basic RFC821/822 parsing 29951222Seric 30051222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later 30155416SericR@ $+ , $+ @ $1 : $2 change all "," to ":" 30251222Seric 30351222Seric# localize and dispose of route-based addresses 30455416SericR@ $+ : $+ $@ $>6 < @$1 > : $2 handle <route-addr> 30551222Seric 30651222Seric# find focus for list syntax 30755416SericR $+ : $* ; @ $+ $@ $>6 $1 : $2 ; < @ $3 > list syntax 30855416SericR $+ : $* ; $@ $1 : $2; list syntax 30951222Seric 31051222Seric# find focus for @ syntax addresses 31155416SericR$+ @ $+ $: $1 < @ $2 > focus on domain 31255416SericR$+ < $+ @ $+ > $1 $2 < @ $3 > move gaze right 31355416SericR$+ < @ $+ > $@ $>6 $1 < @ $2 > already canonical 31451222Seric 31551222Seric# convert old-style addresses to a domain-based address 31655416SericR$- ! $+ $@ $>6 $2 < @ $1 .UUCP > resolve uucp names 31755416SericR$+ . $- ! $+ $@ $>6 $3 < @ $1 . $2 > domain uucps 31855416SericR$+ ! $+ $@ $>6 $2 < @ $1 .UUCP > uucp subdomains 31951222Seric 32051222Seric# if we have % signs, take the rightmost one 32155416SericR$* % $* $1 @ $2 First make them all @s. 32255416SericR$* @ $* @ $* $1 % $2 @ $3 Undo all but the last. 32355416SericR$* @ $* $@ $>6 $1 < @ $2 > Insert < > and finish 32451222Seric 32551222Seric# else we must be a local name 32651222Seric 32751222Seric 32851222Seric############################################### 32951222Seric### Ruleset 6 -- bottom half of ruleset 3 ### 33051222Seric############################################### 33151222Seric 33257245Seric# At this point, everything should be in a "local_part<@domain>extra" format. 33351222SericS6 33451222Seric 33551222Seric# handle special cases for local names 33651322SericR$* < @ $=w > $* $: $1 < @ $j . > $3 no domain at all 33755416SericR$* < @ $=w . UUCP > $* $: $1 < @ $j . > $3 .UUCP domain 33851889Sericundivert(2)dnl 33951222Seric 34051274Sericifdef(`UUCP_RELAY', 34151274Seric`# pass UUCP addresses straight through 34255416SericR$* < @ $+ . UUCP > $* $@ $1 < @ $2 . UUCP > $3', 34351274Seric`# if really UUCP, handle it immediately 34451322Sericifdef(`_CLASS_U_', 34555416Seric`R$* < @ $=U . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 34651322Sericifdef(`_CLASS_V_', 34755416Seric`R$* < @ $=V . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 34851322Sericifdef(`_CLASS_W_', 34955416Seric`R$* < @ $=W . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 35051322Sericifdef(`_CLASS_X_', 35155416Seric`R$* < @ $=X . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 35251322Sericifdef(`_CLASS_Y_', 35355416Seric`R$* < @ $=Y . UUCP > $* $@ $1 < @ $2 . UUCP > $3', `dnl') 35451267Seric 35551267Seric# try UUCP traffic as a local address 35655416SericR$* < @ $+ . UUCP > $* $: $1 < @ $[ $2 $] . UUCP > $3 35751992Sericifdef(`_OLD_SENDMAIL_', 35855416Seric`R$* < @ $+ . $+ . UUCP > $* $@ $1 < @ $2 . $3 . > $4', 35955416Seric`R$* < @ $+ . . UUCP > $* $@ $1 < @ $2 . > $3')') 36051267Seric 36151222Seric# pass to name server to make hostname canonical 36251322SericR$* < @ $* $~. > $* $: $1 < @ $[ $2 $3 $] > $4 36351222Seric 36451889Seric# handle possible alternate names 36551889SericR$* < @ $=w . $m . > $* $: $1 < @ $j . > $3 36651889SericR$* < @ $=w . $m > $* $: $1 < @ $j . > $3 36751889Sericundivert(8)dnl 36851889Seric 36951322Seric# if this is the local hostname, make sure we treat is as canonical 37051322SericR$* < @ $j > $* $: $1 < @ $j . > $2 37151222Seric 37251322Seric 37351222Seric################################################## 37451222Seric### Ruleset 4 -- Final Output Post-rewriting ### 37551222Seric################################################## 37651222SericS4 37751222Seric 37851222SericR@ $@ handle <> error addr 37951222Seric 38051222Seric# resolve numeric addresses to name if possible 38151322SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 lookup numeric internet addr 38251222Seric 38351322Seric# strip trailing dot off possibly canonical name 38451322SericR$* < @ $+ . > $* $1 < @ $2 > $3 38551322Seric 38651222Seric# externalize local domain info 38751322SericR$* < $+ > $* $1 $2 $3 defocus 38851322SericR@ $+ : @ $+ : $+ @ $1 , @ $2 : $3 <route-addr> canonical 38951997SericR@ $* $@ @ $1 ... and exit 39051222Seric 39151222Seric# UUCP must always be presented in old form 39251322SericR$+ @ $- . UUCP $2!$1 u@h.UUCP => h!u 39351222Seric 39451222Seric# delete duplicate local names 39551322SericR$+ % $=w @ $=w $1 @ $j u%host@host => u@host 39651222Seric 39751222Seric 39851222Seric 39951222Seric############################################################# 40051222Seric### Ruleset 7 -- recanonicalize and call ruleset zero ### 40151222Seric### (used for recursive calls) ### 40251222Seric############################################################# 40351222Seric 40451222SericS7 40551222SericR$* $: $>3 $1 40651222SericR$* $@ $>0 $1 40751222Seric 40851222Seric 40951222Seric###################################### 41051222Seric### Ruleset 0 -- Parse Address ### 41151222Seric###################################### 41251222Seric 41351222SericS0 41451222Seric 41555416Sericifdef(`_MAILER_smtp_', 41655416Seric`# handle numeric address spec 41751322SericR$* < @ [ $+ ] > $* $: $1 < @ $[ [$2] $] > $3 numeric internet addr 41855416SericR$* < @ [ $+ ] > $* $#smtp $@ [$2] $: $1 @ [$2] $3 numeric internet spec', 41956785Seric`dnl') 42051222Seric 42151887Seric# now delete the local info -- note $=O to find characters that cause forwarding 42251322SericR< @ $j . > : $* $@ $>7 $1 @here:... -> ... 42351322SericR$* $=O $* < @ $j . > $@ $>7 $1 $2 $3 ...@here -> ... 42451222Seric 42551222Seric# short circuit local delivery so forwarded email works 42657527SericR$+ < @ $j . > $: $1 < @ $j @ $H > first try hub 42751992Sericifdef(`_OLD_SENDMAIL_', 42857527Seric`R$+ < $+ @ $+ > $#smtp $@ $3 $: $1 < $2 > yep .... 42957527SericR$+ < $+ @ > $#local $: $1 nope, local address', 43057527Seric`R$+ < $+ @ $+ > $#local $: $1 yep .... 43157527SericR$+ < $+ @ > $#local $: @ $1 nope, local address') 43251222Sericundivert(3)dnl 43351260Sericundivert(4)dnl 43451260Seric 43555416Seric# resolve remotely connected UUCP links (if any) 43651285Sericifdef(`_CLASS_V_', 43752044Seric`R$* < @ $=V . UUCP > $* $#smtp $@ $V $: <@ $V> : $1 @ $2.UUCP $3', 43852044Seric `dnl') 43951285Sericifdef(`_CLASS_W_', 44052044Seric`R$* < @ $=W . UUCP > $* $#smtp $@ $W $: <@ $W> : $1 @ $2.UUCP $3', 44152044Seric `dnl') 44251285Sericifdef(`_CLASS_X_', 44352044Seric`R$* < @ $=X . UUCP > $* $#smtp $@ $X $: <@ $X> : $1 @ $2.UUCP $3', 44452044Seric `dnl') 44551260Seric 44651222Seric# resolve fake top level domains by forwarding to other hosts 44751222Sericifdef(`BITNET_RELAY', 44852044Seric`R$*<@$+.BITNET>$* $#smtp $@ $B $: $1 <@$2.BITNET> $3 user@host.BITNET', 44951222Seric `dnl') 45051222Sericifdef(`CSNET_RELAY', 45152044Seric`R$*<@$+.CSNET>$* $#smtp $@ $C $: $1 <@$2.CSNET> $3 user@host.CSNET', 45251222Seric `dnl') 45351222Seric 45451260Sericifdef(`UUCP_RELAY', 45551260Seric`# forward non-local UUCP traffic to our UUCP relay 45652044SericR$*<@$*.UUCP>$* $#smtp $@ $Y $: <@ $Y> : $1 @ $2.UUCP $3 uucp mail', 45755416Seric`ifdef(`_MAILER_uucp_', 45851260Seric`# forward other UUCP traffic straight to UUCP 45951260SericR< @ $+ .UUCP > : $+ $#uucp $@ $1 $: $1:$2 @host.UUCP:... 46051322SericR$+ < @ $+ .UUCP > $#uucp $@ $2 $: $1 user@host.UUCP', 46151260Seric `dnl')') 46251222Seric 46355416Sericifdef(`_MAILER_smtp_', 46455416Seric`# deal with other remote names 46552041SericR$* < @ $* > $* $#smtp $@ $2 $: $1 < @ $2 > $3 user@host.domain 46655416Seric', `dnl') 46751222Seric 46851992Sericifdef(`_OLD_SENDMAIL_', 46951887Seric`# forward remaining names to local relay, if any 47052041SericR$=L $#local $: $1 special local names 47152041SericR$+ $: $1 < @ $R > append relay 47257527SericR$+ < @ > $: $1 < @ $H > no relay, try hub 47357527SericR$+ < @ > $#local $: $1 no relay or hub: local 47457527SericR$+ < @ $j > $#local $: $1 we are relay/hub: local 47557527SericR$+ < @ $+ > $#smtp $@ $2 $: $1 deliver to relay/hub', 47651992Seric`# handle locally delivered names 47752041SericR$=L $#local $: @ $1 special local names 47852041SericR$+ $#local $: $1 regular local names 47951222Seric 48055416Seric########################################################################### 48155416Seric### Ruleset 5 -- special rewriting after aliases have been expanded ### 48255416Seric### (new sendmail only) ### 48355416Seric########################################################################### 48451222Seric 48551322SericS5 48651322Seric 48755416Sericifdef(`_MAILER_smtp_', 48855416Seric`R$+ $: $1 < @ $R > 48957527SericR$+ < @ > $: $1 < @ $H > no relay, try hub 49057527SericR$+ < @ $j > $@ $1 we are relay/hub: local 49157527SericR$+ < @ $+ > $#smtp $@ $2 $: $1 send to relay or hub')') 49251222Seric# 49351222Seric###################################################################### 49451222Seric###################################################################### 49551222Seric##### 49656790Seric`##### MAILER DEFINITIONS' 49751222Seric##### 49851222Seric###################################################################### 49951222Seric###################################################################### 50051222Sericundivert(7)dnl 501