xref: /csrg-svn/usr.sbin/sendmail/cf/m4/proto.m4 (revision 63973)
151222Sericdivert(-1)
251222Seric#
351222Seric# Copyright (c) 1983 Eric P. Allman
463592Sbostic# Copyright (c) 1988, 1993
563592Sbostic#	The Regents of the University of California.  All rights reserved.
651222Seric#
751222Seric# %sccs.include.redist.sh%
851222Seric#
951222Sericdivert(0)
1051222Seric
11*63973SericVERSIONID(`@(#)proto.m4	8.7 (Berkeley) 07/21/93')
1251222Seric
1351322SericMAILER(local)dnl
1451222Seric
1560894Sericifdef(`_OLD_SENDMAIL_',
1660894Seric`define(`_SET_96_', 6)dnl
1763858Sericdefine(`_SET_97_', 7)dnl
1863858Sericdefine(`_SET_98_', 8)dnl',
1958119Seric`# level 4 config file format
2060894SericV4
2160894Sericdefine(`_SET_96_', 96)dnl
2263858Sericdefine(`_SET_97_', 97)dnl
2363858Sericdefine(`_SET_98_', 98)dnl')
24*63973Sericifdef(`confSMTP_MAILER',, `define(`confSMTP_MAILER', `esmtp')')dnl
25*63973Sericdefine(`_SMTP_', `confSMTP_MAILER')dnl	for readability only
2652646Seric
2751222Seric##################
2851222Seric#   local info   #
2951222Seric##################
3051222Seric
3160212SericCP.
3260212Seric
3351889SericCwlocalhost
3451887Sericifdef(`USE_CW_FILE',
3551889Seric`# file containing names of hosts for which we receive email
3658406SericCONCAT(`Fw', confCW_FILE)', `dnl')
3751222Seric
3851222Sericifdef(`UUCP_RELAY',
3951222Seric`# UUCP relay host
4051281SericCONCAT(DY, UUCP_RELAY)
4160212SericCPUUCP
4257944Seric
4351222Seric')dnl
4451222Sericifdef(`BITNET_RELAY',
4551222Seric`#  BITNET relay host
4651222SericCONCAT(DB, BITNET_RELAY)
4760212SericCPBITNET
4857944Seric
4951222Seric')dnl
5051222Sericifdef(`CSNET_RELAY',
5151222Seric`# CSNET relay host
5251222SericCONCAT(DC, CSNET_RELAY)
5360212SericCPCSNET
5457944Seric
5551222Seric')dnl
5658364Sericifdef(`FAX_RELAY',
5758364Seric`# FAX relay host
5858364SericCONCAT(DF, FAX_RELAY)
5960212SericCPFAX
6058364Seric
6158364Seric')dnl
6258070Sericifdef(`SMART_HOST',
6358070Seric`# "Smart" UUCP relay host
6458070SericCONCAT(DS, SMART_HOST)
6551222Seric
6658070Seric')dnl
6758781Sericifdef(`MAILER_TABLE',
6858781Seric`# Mailer table (overriding domains)
6958781SericKmailertable MAILER_TABLE
7058781Seric
7158781Seric')dnl
7263754Sericifdef(`DOMAIN_TABLE',
7363754Seric`# Domain table (adding domains)
7463754SericKdomaintable DOMAIN_TABLE
7563754Seric
7663754Seric')dnl
7751222Seric# who I send unqualified names to (null means deliver locally)
7851222SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
7951222Seric
8057527Seric# who gets all local email traffic ($R has precedence for unqualified names)
8157527SericCONCAT(DH, ifdef(`MAIL_HUB', MAIL_HUB))
8257527Seric
8358070Seric# my official hostname ($w or $w.$D)
8458070SericCONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D))
8558070Seric
8658070Seric# who I masquerade as (can be $j)
8758070SericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j))
8858070Seric
8957245Seric# class L: names that should be delivered locally, even if we have a relay
9057245Seric# class E: names that should be exposed as from this host, even if we masquerade
9151279SericCLroot
9257245SericCEroot
9351279Sericundivert(5)dnl
9451279Seric
9551222Seric# operators that cannot be in local usernames (i.e., network indicators)
9658288SericCO @ % ifdef(`_NO_UUCP_', `', `!')
9751222Seric
9851322Seric# a class with just dot (for identifying canonical names)
9951322SericC..
10051322Seric
10158808Sericifdef(`_OLD_SENDMAIL_', `dnl',
10258808Seric`# dequoting map
10358808SericKdequote dequote')
10457944Seric
10559033Sericundivert(6)dnl
10659033Seric
10757944Seric######################
10857944Seric#   Special macros   #
10957944Seric######################
11057944Seric
11157944Seric# SMTP initial login message
11257944SericCONCAT(De, confSMTP_LOGIN_MSG)
11357944Seric
11457944Seric# UNIX initial From header format
11557944SericCONCAT(Dl, confFROM_LINE)
11657944Seric
11757944Seric# my name for error messages
11857944SericCONCAT(Dn, confMAILER_NAME)
11957944Seric
12057944Seric# delimiter (operator) characters
12157944SericCONCAT(Do, confOPERATORS)
12257944Seric
12357944Seric# format of a total name
12457944SericCONCAT(Dq, ifdef(`confFROM_HEADER', confFROM_HEADER,
12557944Seric	ifdef(`_OLD_SENDMAIL_', `$g$?x ($x)$.', `$?x$x <$g>$|$g$.')))
12657944Sericinclude(`../m4/version.m4')
12757944Seric
12857944Seric###############
12957944Seric#   Options   #
13057944Seric###############
13157944Seric
13259887Seric# strip message body to 7 bits on input?
13359887SericCONCAT(O7, confSEVEN_BIT_INPUT)
13457944Seric
13557944Seric# wait (in minutes) for alias file rebuild
13657944SericCONCAT(Oa, confALIAS_WAIT)
13757944Seric
13857944Seric# location of alias file
13957944SericCONCAT(OA, ifdef(`ALIAS_FILE', ALIAS_FILE, /etc/aliases))
14057944Seric
14158084Seric# minimum number of free blocks on filesystem
14258084SericCONCAT(Ob, confMIN_FREE_BLOCKS)
14358084Seric
14457944Seric# substitution for space (blank) characters
14557944SericCONCAT(OB, confBLANK_SUB)
14657944Seric
14757944Seric# connect to "expensive" mailers on initial submission?
14857944SericCONCAT(Oc, confCON_EXPENSIVE)
14957944Seric
15057944Seric# checkpoint queue runs after every N successful deliveries
15157944SericCONCAT(OC, confCHECKPOINT_INTERVAL)
15257944Seric
15357944Seric# default delivery mode
15457944SericCONCAT(Od, confDELIVERY_MODE)
15557944Seric
15657944Seric# automatically rebuild the alias database?
15757944SericCONCAT(OD, confAUTO_REBUILD)
15857944Seric
15957944Seric# error message header/file */
16057944Sericifdef(`confERROR_MESSAGE',
16163583Seric	CONCAT(OE, confERROR_MESSAGE),
16257944Seric	#OE/etc/sendmail.oE)
16357944Seric
16457944Seric# error mode
16557944Sericifdef(`confERROR_MODE',
16663583Seric	CONCAT(Oe, confERROR_MODE),
16757944Seric	#Oep)
16857944Seric
16957944Seric# save Unix-style "From_" lines at top of header?
17057944SericCONCAT(Of, confSAVE_FROM_LINES)
17157944Seric
17257944Seric# temporary file mode
17357944SericCONCAT(OF, confTEMP_FILE_MODE)
17457944Seric
17557944Seric# match recipients against GECOS field?
17657944SericCONCAT(OG, confMATCH_GECOS)
17757944Seric
17857944Seric# default GID
17957944SericCONCAT(Og, confDEF_GROUP_ID)
18057944Seric
18157944Seric# maximum hop count
18257944SericCONCAT(Oh, confMAX_HOP)
18357944Seric
18457944Seric# location of help file
18557944SericCONCAT(OH, ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf))
18657944Seric
18757944Seric# ignore dots as terminators in incoming messages?
18857944SericCONCAT(Oi, confIGNORE_DOTS)
18957944Seric
19057944Seric# Insist that the BIND name server be running to resolve names
19157944Sericifdef(`confBIND_OPTS',
19257944Seric	CONCAT(OI, confBIND_OPTS),
19357944Seric	#OI)
19457944Seric
19559887Seric# deliver MIME-encapsulated error messages?
19659887SericCONCAT(Oj, confMIME_FORMAT_ERRORS)
19759887Seric
19857944Seric# Forward file search path
19957944Sericifdef(`confFORWARD_PATH',
20057944Seric	CONCAT(OJ, confFORWARD_PATH),
20157944Seric	#OJ/var/forward/$u:$z/.forward.$w:$z/.forward)
20257944Seric
20357944Seric# open connection cache size
20457944SericCONCAT(Ok, confMCI_CACHE_SIZE)
20557944Seric
20657944Seric# open connection cache timeout
20757944SericCONCAT(OK, confMCI_CACHE_TIMEOUT)
20857944Seric
20961106Seric# use Errors-To: header?
21061106SericCONCAT(Ol, confUSE_ERRORS_TO)
21161106Seric
21257944Seric# log level
21357944SericCONCAT(OL, confLOG_LEVEL)
21457944Seric
21557944Seric# send to me too, even in an alias expansion?
21657944SericCONCAT(Om, confME_TOO)
21757944Seric
21857944Seric# verify RHS in newaliases?
21957944SericCONCAT(On, confCHECK_ALIASES)
22057944Seric
22157944Seric# default messages to old style headers if no special punctuation?
22257944SericCONCAT(Oo, confOLD_STYLE_HEADERS)
22357944Seric
22458860Seric# SMTP daemon options
22558860Sericifdef(`confDAEMON_OPTIONS',
22658860Seric	CONCAT(OO, confDAEMON_OPTIONS),
22758860Seric	#OOPort=esmtp)
22858860Seric
22958084Seric# privacy flags
23058084SericCONCAT(Op, confPRIVACY_FLAGS)
23158084Seric
23257944Seric# who (if anyone) should get extra copies of error messages
23357944Sericifdef(`confCOPY_ERRORS_TO',
23457944Seric	CONCAT(OP, confCOPY_ERRORS_TO),
23557944Seric	#OPPostmaster)
23657944Seric
23757944Seric# slope of queue-only function
23857944Sericifdef(`confQUEUE_FACTOR',
23957944Seric	CONCAT(Oq, confQUEUE_FACTOR),
24057944Seric	#Oq600000)
24157944Seric
24257944Seric# queue directory
24357944SericCONCAT(OQ, ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue))
24457944Seric
24557944Seric# read timeout -- now OK per RFC 1123 section 5.3.2
24658119Sericifdef(`confREAD_TIMEOUT',
24758119Seric	CONCAT(Or, confREAD_TIMEOUT),
24858119Seric	#Ordatablock=10m)
24957944Seric
25057944Seric# queue up everything before forking?
25157944SericCONCAT(Os, confSAFE_QUEUE)
25257944Seric
25357944Seric# status file
25457944SericCONCAT(OS, ifdef(`STATUS_FILE', STATUS_FILE, /etc/sendmail.st))
25557944Seric
25657944Seric# default message timeout interval
25757944SericCONCAT(OT, confMESSAGE_TIMEOUT)
25857944Seric
25957944Seric# time zone handling:
26057944Seric#  if undefined, use system default
26157944Seric#  if defined but null, use TZ envariable passed in
26257944Seric#  if defined and non-null, use that info
26357944Sericifelse(confTIME_ZONE, `USE_SYSTEM', `#Ot',
26457944Seric	confTIME_ZONE, `USE_TZ', `',
26557944Seric	`CONCAT(Ot, confTIME_ZONE)')
26657944Seric
26757944Seric# default UID
26857944SericCONCAT(Ou, confDEF_USER_ID)
26957944Seric
27051887Seric# list of locations of user database file (null means no lookup)
27158720SericOU`'ifdef(`confUSERDB_SPEC', `confUSERDB_SPEC')
27251222Seric
27358860Seric# fallback MX host
27458860Sericifdef(`confFALLBACK_MX',
27558860Seric	CONCAT(OV, confFALLBACK_MX),
27658860Seric	#OVfall.back.host.net)
27758860Seric
27863858Seric# if we are the best MX host for a site, try it directly instead of config err
27963858SericCONCAT(Ow, confTRY_NULL_MX_LIST)
28063858Seric
28157944Seric# load average at which we just queue messages
28257944SericCONCAT(Ox, confQUEUE_LA)
28357944Seric
28457944Seric# load average at which we refuse connections
28557944SericCONCAT(OX, confREFUSE_LA)
28657944Seric
28757944Seric# work recipient factor
28857944Sericifdef(`confWORK_RECIPIENT_FACTOR',
28957944Seric	CONCAT(Oy, confWORK_RECIPIENT_FACTOR),
29057944Seric	#Oy30000)
29157944Seric
29257944Seric# deliver each queued job in a separate process?
29357944SericCONCAT(OY, confSEPARATE_PROC)
29457944Seric
29557944Seric# work class factor
29657944Sericifdef(`confWORK_CLASS_FACTOR',
29757944Seric	CONCAT(Oz, confWORK_CLASS_FACTOR),
29857944Seric	#Oz1800)
29957944Seric
30057944Seric# work time factor
30157944Sericifdef(`confWORK_TIME_FACTOR',
30257944Seric	CONCAT(OZ, confWORK_TIME_FACTOR),
30357944Seric	#OZ90000)
30457944Seric
30557944Seric###########################
30657944Seric#   Message precedences   #
30757944Seric###########################
30857944Seric
30957944SericPfirst-class=0
31057944SericPspecial-delivery=100
31158070SericPlist=-30
31257944SericPbulk=-60
31357944SericPjunk=-100
31457944Seric
31557944Seric#####################
31657944Seric#   Trusted users   #
31757944Seric#####################
31857944Seric
31957944SericTroot
32057944SericTdaemon
32157944SericTuucp
32257944Seric
32357944Seric#########################
32457944Seric#   Format of headers   #
32557944Seric#########################
32657944Seric
32758679SericH?P?Return-Path: $g
32860894SericHReceived: $?sfrom $s $.$?_($_) $.by $j ($v/$Z)$?r with $r$. id $i; $b
32957944SericH?D?Resent-Date: $a
33057944SericH?D?Date: $a
33157944SericH?F?Resent-From: $q
33257944SericH?F?From: $q
33357944SericH?x?Full-Name: $x
33457944SericHSubject:
33557944Seric# HPosted-Date: $a
33657944Seric# H?l?Received-Date: $b
33757944SericH?M?Resent-Message-Id: <$t.$i@$j>
33857944SericH?M?Message-Id: <$t.$i@$j>
33951222Seric#
34051222Seric######################################################################
34151222Seric######################################################################
34251222Seric#####
34351222Seric#####			REWRITING RULES
34451222Seric#####
34551222Seric######################################################################
34651222Seric######################################################################
34751222Seric
34858678Sericundivert(9)dnl
34951222Seric
35051222Seric###########################################
35151222Seric###  Rulset 3 -- Name Canonicalization  ###
35251222Seric###########################################
35351260SericS3
35451222Seric
35558499Seric# handle null input and list syntax (translate to <@> special case)
35658499SericR$@			$@ <@>
35758707SericR$*:;$*			$@ $1 :; <@>
35858174Seric
35951222Seric# basic textual canonicalization -- note RFC733 heuristic here
36057012SericR$*<$*>$*<$*>$*		<$2>$3$4$5			strip multiple <> <>
36158158SericR$*<$*<$+>$*>$*		<$3>$5				2-level <> nesting
36258499SericR$*<>$*			$@ <@>				MAIL FROM:<> case
36351222SericR$*<$+>$*		$2				basic RFC821/822 parsing
36451222Seric
36551222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
36655416SericR@ $+ , $+		@ $1 : $2			change all "," to ":"
36751222Seric
36851222Seric# localize and dispose of route-based addresses
36960894SericR@ $+ : $+		$@ $>_SET_96_ < @$1 > : $2		handle <route-addr>
37051222Seric
37151222Seric# find focus for list syntax
37260894SericR $+ : $* ; @ $+	$@ $>_SET_96_ $1 : $2 ; < @ $3 >	list syntax
37355416SericR $+ : $* ;		$@ $1 : $2;			list syntax
37451222Seric
37551222Seric# find focus for @ syntax addresses
37655416SericR$+ @ $+		$: $1 < @ $2 >			focus on domain
37755416SericR$+ < $+ @ $+ >		$1 $2 < @ $3 >			move gaze right
37860894SericR$+ < @ $+ >		$@ $>_SET_96_ $1 < @ $2 >		already canonical
37951222Seric
38058288Sericifdef(`_NO_UUCP_', `dnl',
38158288Seric`# convert old-style addresses to a domain-based address
38260894SericR$- ! $+		$@ $>_SET_96_ $2 < @ $1 .UUCP >	resolve uucp names
38360894SericR$+ . $- ! $+		$@ $>_SET_96_ $3 < @ $1 . $2 >		domain uucps
38460894SericR$+ ! $+		$@ $>_SET_96_ $2 < @ $1 .UUCP >	uucp subdomains')
38551222Seric
38651222Seric# if we have % signs, take the rightmost one
38755416SericR$* % $*		$1 @ $2				First make them all @s.
38855416SericR$* @ $* @ $*		$1 % $2 @ $3			Undo all but the last.
38960894SericR$* @ $*		$@ $>_SET_96_ $1 < @ $2 >		Insert < > and finish
39051222Seric
39151222Seric# else we must be a local name
39251222Seric
39351222Seric
39460894Seric################################################
39560894Seric###  Ruleset _SET_96_ -- bottom half of ruleset 3  ###
39660894Seric################################################
39751222Seric
39857245Seric#  At this point, everything should be in a "local_part<@domain>extra" format.
39960894SericS`'_SET_96_
40051222Seric
40151222Seric# handle special cases for local names
40260262SericR$* < @ localhost > $*		$: $1 < @ $j . > $2		no domain at all
40360262SericR$* < @ localhost . $m > $*	$: $1 < @ $j . > $2		local domain
40460262Sericifdef(`_NO_UUCP_', `dnl',
40560262Seric`R$* < @ localhost . UUCP > $*	$: $1 < @ $j . > $2		.UUCP domain')
40663754Sericifdef(`DOMAIN_TABLE', `
40763754Seric# look up unqualified domains in the domain table
40863754SericR$* < @ $- > $*			$: $1 < @ $(domaintable $2 $) > $3',
40963754Seric`dnl')
41051889Sericundivert(2)dnl
41151222Seric
41259081Sericifdef(`_NO_UUCP_', `dnl',
41359081Seric`ifdef(`UUCP_RELAY',
41451274Seric`# pass UUCP addresses straight through
41555416SericR$* < @ $+ . UUCP > $*		$@ $1 < @ $2 . UUCP > $3',
41651274Seric`# if really UUCP, handle it immediately
41751322Sericifdef(`_CLASS_U_',
41855416Seric`R$* < @ $=U . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
41951322Sericifdef(`_CLASS_V_',
42055416Seric`R$* < @ $=V . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
42151322Sericifdef(`_CLASS_W_',
42255416Seric`R$* < @ $=W . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
42351322Sericifdef(`_CLASS_X_',
42455416Seric`R$* < @ $=X . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
42551322Sericifdef(`_CLASS_Y_',
42655416Seric`R$* < @ $=Y . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
42751267Seric
42851267Seric# try UUCP traffic as a local address
42955416SericR$* < @ $+ . UUCP > $*		$: $1 < @ $[ $2 $] . UUCP > $3
43051992Sericifdef(`_OLD_SENDMAIL_',
43155416Seric`R$* < @ $+ . $+ . UUCP > $*		$@ $1 < @ $2 . $3 . > $4',
43255416Seric`R$* < @ $+ . . UUCP > $*		$@ $1 < @ $2 . > $3')')
43359081Seric')
43461470Sericifdef(`_NO_CANONIFY_',
43561470Seric`# make sure local host names appear canonical
43661470SericR$* < @ $=w > $*		$: $1 < @ $2 . > $3',
43759081Seric`# pass to name server to make hostname canonical
43861470SericR$* < @ $* $~P > $*		$: $1 < @ $[ $2 $3 $] > $4')
43961470Seric
44051889Sericundivert(8)dnl
44151889Seric
44251322Seric# if this is the local hostname, make sure we treat is as canonical
44351322SericR$* < @ $j > $*			$: $1 < @ $j . > $2
44451222Seric
44551322Seric
44651222Seric##################################################
44751222Seric###  Ruleset 4 -- Final Output Post-rewriting  ###
44851222Seric##################################################
44951222SericS4
45051222Seric
45158499SericR$*<@>			$@ $1				handle <> and list:;
45251222Seric
45351222Seric# resolve numeric addresses to name if possible
45451322SericR$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	lookup numeric internet addr
45551222Seric
45651322Seric# strip trailing dot off possibly canonical name
45751322SericR$* < @ $+ . > $*	$1 < @ $2 > $3
45851322Seric
45951222Seric# externalize local domain info
46051322SericR$* < $+ > $*		$1 $2 $3			defocus
46151322SericR@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
46251997SericR@ $*			$@ @ $1				... and exit
46351222Seric
46458288Sericifdef(`_NO_UUCP_', `dnl',
46558288Seric`# UUCP must always be presented in old form
46658288SericR$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u')
46751222Seric
46851222Seric# delete duplicate local names
46951322SericR$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
47051222Seric
47151222Seric
47251222Seric
47360894Seric##############################################################
47460894Seric###   Ruleset _SET_97_ -- recanonicalize and call ruleset zero   ###
47560894Seric###		   (used for recursive calls)		   ###
47660894Seric##############################################################
47751222Seric
47860894SericS`'_SET_97_
47951222SericR$*			$: $>3 $1
48051222SericR$*			$@ $>0 $1
48151222Seric
48251222Seric
48351222Seric######################################
48451222Seric###   Ruleset 0 -- Parse Address   ###
48551222Seric######################################
48651222Seric
48751222SericS0
48851222Seric
48958562SericR<@>			$#local $: <>			special case error msgs
49059887SericR$*:;<@>		$#error $@ USAGE $: "list:; syntax illegal for recipient addresses"
49158340Seric
49255416Sericifdef(`_MAILER_smtp_',
49355416Seric`# handle numeric address spec
49463860Sericifdef(`_NO_CANONIFY_', `dnl',
49563860Seric`R$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	numeric internet addr')
49663858SericR$* < @ [ $+ ] > $*	$: $>_SET_98_ $1 < @ [ $2 ] > $3	numeric internet spec
497*63973SericR$* < @ [ $+ ] > $*	$#_SMTP_ $@ [$2] $: $1 @ [$2] $3	still numeric: send',
49863858Seric	`dnl')
49951222Seric
50051887Seric# now delete the local info -- note $=O to find characters that cause forwarding
50160894SericR$* < @ > $*		$@ $>_SET_97_ $1			user@ => user
50260894SericR< @ $=w . > : $*	$@ $>_SET_97_ $2			@here:... -> ...
50360894SericR$* $=O $* < @ $=w . >	$@ $>_SET_97_ $1 $2 $3			...@here -> ...
50463967Seric
50563967Seric# handle local hacks
50663967SericR$*			$: $>_SET_98_ $1
50758781Sericifdef(`MAILER_TABLE',
50858781Seric`
50958781Seric# try mailer table lookup
51060540SericR$* <@ $+ > $*		$: < $2 > $1 < @ $2 > $3	extract host name
51161106SericR< $+ . > $*		$: < $1 > $2			strip trailing dot
51262582SericR< $+ > $*		$: < $(mailertable $1 $) > $2	lookup
51361106SericR< $- : $+ > $*		$# $1 $@ $2 $: $3		check -- resolved?
51462582SericR< $+ > $*		$: $>90 <$1> $2			try domain',
51558781Seric`dnl')
51651222Seric
51751222Seric# short circuit local delivery so forwarded email works
51858516Sericifdef(`_LOCAL_NOT_STICKY_',
51960894Seric`R$=L < @ $=w . >		$#local $: @ $1			special local names
52060894SericR$+ < @ $=w . >		$#local $: $1			dispose directly',
52160894Seric`R$+ < @ $=w . >		$: $1 < @ $2 @ $H >		first try hub
52251992Sericifdef(`_OLD_SENDMAIL_',
52359635Seric`R$+ < $+ @ $-:$+ >	$# $3 $@ $4 $: $1 < $2 >	yep ....
52459635SericR$+ < $+ @ $+ >		$#relay $@ $3 $: $1 < $2 >	yep ....
52557527SericR$+ < $+ @ >		$#local $: $1			nope, local address',
52657527Seric`R$+ < $+ @ $+ >		$#local $: $1			yep ....
52758516SericR$+ < $+ @ >		$#local $: @ $1			nope, local address')')
52851260Sericundivert(4)dnl
52951260Seric
53061468Sericifdef(`_NO_UUCP_', `dnl',
53161468Seric`# resolve remotely connected UUCP links (if any)
53251285Sericifdef(`_CLASS_V_',
53363858Seric`R$* < @ $=V . UUCP > $*		$: < $V > <@ $V> : $1 @ $2.UUCP $3
53463858SericR< $- : $+ > $*			$# $1 $@ $2 $: $3	$=V UUCP routing
535*63973SericR< $+ > $*			$#_SMTP_ $@ $1 $: $2
53663858SericR<> $*				$: $1			else strip off gunk',
53752044Seric	`dnl')
53851285Sericifdef(`_CLASS_W_',
53963858Seric`R$* < @ $=W . UUCP > $*		$: < $W > <@ $W> : $1 @ $2.UUCP $3
54063858SericR< $- : $+ > $*			$# $1 $@ $2 $: $3	$=W UUCP routing
541*63973SericR< $+ > $*			$#_SMTP_ $@ $1 $: $2
54263858SericR<> $*				$: $1			else strip off gunk',
54352044Seric	`dnl')
54451285Sericifdef(`_CLASS_X_',
54563858Seric`R$* < @ $=X . UUCP > $*		$: < $X > <@ $X> : $1 @ $2.UUCP $3
54663858SericR< $- : $+ > $*			$# $1 $@ $2 $: $3	$=X UUCP routing
547*63973SericR< $+ > $*			$#_SMTP_ $@ $1 $: $2
54863858SericR<> $*				$: $1			else strip off gunk',
54961468Seric	`dnl')')
55051260Seric
55151222Seric# resolve fake top level domains by forwarding to other hosts
55251222Sericifdef(`BITNET_RELAY',
55363858Seric`R$*<@$+.BITNET>$*	$: < $B > $1 <@$2.BITNET> $3	user@host.BITNET
55463858SericR< $- : $+ > $*		$# $1 $@ $2 $: $3
555*63973SericR< $+ > $*		$#_SMTP_ $@ $1 $: $2
55663858SericR<> $*			$: $1				else strip off gunk',
55751222Seric	`dnl')
55851222Sericifdef(`CSNET_RELAY',
55963858Seric`R$*<@$+.CSNET>$*	$: < $C > $1 <@$2.CSNET> $3	user@host.CSNET
56063858SericR< $- : $+ > $*		$# $1 $@ $2 $: $3
561*63973SericR< $+ > $*		$#_SMTP_ $@ $1 $: $2
56263858SericR<> $*			$: $1				else strip off gunk',
56351222Seric	`dnl')
56458364Sericifdef(`_MAILER_fax_',
56563858Seric`R$+ < @ $+ .FAX >	$#fax $@ $2 $: $1		user@host.FAX',
56658364Seric`ifdef(`FAX_RELAY',
56763858Seric`R$*<@$+.FAX>$*		$: < $F > $1 <@$2.FAX> $3	user@host.FAX
56863858SericR< $- : $+ > $*		$# $1 $@ $2 $: $3
569*63973SericR< $+ > $*		$#_SMTP_ $@ $1 $: $2
57063858SericR<> $*			$: $1				else strip off gunk',
57158364Seric	`dnl')')
57251222Seric
57351260Sericifdef(`UUCP_RELAY',
57451260Seric`# forward non-local UUCP traffic to our UUCP relay
57563858SericR$*<@$*.UUCP>$*		$: < $Y > <@ $Y> : $1 @ $2.UUCP $3	uucp mail
57663858SericR< $- : $+ > $*		$# $1 $@ $2 $: $3
577*63973SericR< $+ > $*		$#_SMTP_ $@ $1 $: $2
57863858SericR<> $*			$: $1				else strip off gunk',
57955416Seric`ifdef(`_MAILER_uucp_',
58051260Seric`# forward other UUCP traffic straight to UUCP
58163858SericR< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $2		@host.UUCP:...
58263858SericR$+ < @ $+ .UUCP >	$#uucp $@ $2 $: $1		user@host.UUCP',
58351260Seric	`dnl')')
58463967Sericifdef(`_MAILER_usenet_', `
58563754Seric# addresses sent to net.group.USENET will get forwarded to a newsgroup
58663754SericR$+ . USENET		$# usenet $: $1',
58763860Seric	`dnl')
58863754Seric
58958070Sericifdef(`_LOCAL_RULES_',
59058070Seric`# figure out what should stay in our local mail system
59163754Sericundivert(1)', `dnl')
59263754Seric
59363946Sericifdef(`SMART_HOST',
59463946Seric`# pass names that still have a host to a smarthost
59558070SericR$* < @ $* > $*		$: < $S > $1 < @ $2 > $3	glue on smarthost name
59663858SericR< $- : $+ > $*		$# $1 $@ $2 $: $3		if non-null, use it
59763858SericR< $+ > $*		$#suucp $@ $1 $: $2		if non-null, use it
59863858SericR<> $*			$: $1				else strip off gunk',
59963754Seric
60063754Seric`# deal with other remote names
60163946Sericifdef(`_MAILER_smtp_',
602*63973Seric`R$* < @$* > $*		$#_SMTP_ $@ $2 $: $1 < @ $2 > $3		user@host.domain',
60363946Seric`R$* < @$* > $*		$#error $@NOHOST $: Unrecognized host name $2')')
60451222Seric
60551992Sericifdef(`_OLD_SENDMAIL_',
60651887Seric`# forward remaining names to local relay, if any
60752041SericR$=L			$#local $: $1			special local names
60852041SericR$+			$: $1 < @ $R >			append relay
60957527SericR$+ < @ >		$: $1 < @ $H >			no relay, try hub
61057527SericR$+ < @ >		$#local $: $1			no relay or hub: local
61160894SericR$+ < @ $=w  >		$#local $: $1			we are relay/hub: local
61258070SericR$+ < @ $-:$+ >		$# $2 $@ $3 $: $1		deliver to relay/hub
61358771SericR$+ < @ $+ >		$#relay $@ $2 $: $1		deliver to relay/hub',
61458811Seric
61558811Seric`# if this is quoted, strip the quotes and try again
61658811SericR$+			$: $(dequote $1 $)		strip quotes
61760894SericR$* $=O $*		$@ $>_SET_97_ $1 $2 $3			try again
61858811Seric
61958811Seric# handle locally delivered names
62052041SericR$=L			$#local $: @ $1			special local names
62152041SericR$+			$#local $: $1			regular local names
62251222Seric
62355416Seric###########################################################################
62455416Seric###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
62555416Seric###		   (new sendmail only)					###
62655416Seric###########################################################################
62751222Seric
62851322SericS5
62951322Seric
63058808Seric# see if we have a relay or a hub
63158808SericR$+			$: $1 < @ $R >
63257527SericR$+ < @ >		$: $1 < @ $H >			no relay, try hub
63360894SericR$+ < @ $=w >		$@ $1				we are relay/hub: local
63458070SericR$+ < @ $-:$+ >		$# $2 $@ $3 $: $1		send to relay or hub
63558808Sericifdef(`_MAILER_smtp_',
63658808Seric`R$+ < @ $+ >		$#relay $@ $2 $: $1		send to relay or hub')')
63760540Sericifdef(`MAILER_TABLE',
63860540Seric`
63960540Seric
64063858Seric###################################################################
64163858Seric###  Ruleset 90 -- try domain part of mailertable entry 	###
64263858Seric###		   (new sendmail only)				###
64363858Seric###################################################################
64460540Seric
64560540SericS90
64661106SericR<$- . $+ > $*		$: < $(mailertable .$2 $) > $3	lookup
64760540SericR<$- : $+ > $*		$# $1 $@ $2 $: $3		check -- resolved?
64862372SericR< . $+ > $*		$@ $>90 <$1> $2			no -- strip & try again
64960540SericR<$*> $*		$@ $2				no match',
65060540Seric`dnl')
65163858Seric
65263858Seric###################################################################
65363858Seric###  Ruleset _SET_98_ -- local part of ruleset zero (can be null)	###
65463858Seric###################################################################
65563858Seric
65663858SericS`'_SET_98_
65763858Sericundivert(3)dnl
65851222Seric#
65951222Seric######################################################################
66051222Seric######################################################################
66151222Seric#####
66256790Seric`#####			MAILER DEFINITIONS'
66351222Seric#####
66451222Seric######################################################################
66551222Seric######################################################################
66651222Sericundivert(7)dnl
667