xref: /csrg-svn/usr.sbin/sendmail/cf/m4/proto.m4 (revision 64802)
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*64802SericVERSIONID(`@(#)proto.m4	8.20 (Berkeley) 10/31/93')
1251222Seric
1351322SericMAILER(local)dnl
1451222Seric
1560894Sericifdef(`_OLD_SENDMAIL_',
1664010Seric`define(`_SET_95_', 5)dnl
1764010Sericdefine(`_SET_96_', 6)dnl
1863858Sericdefine(`_SET_97_', 7)dnl
1964260Sericdefine(`_SET_98_', 8)dnl
2064260Sericdefine(`confDOMAIN_NAME',
2164260Seric	`ifdef(`NEED_DOMAIN', `$w.$d', `$w')')dnl',
2264260Seric`# level 5 config file format
2364260SericV5
2464010Sericdefine(`_SET_95_', 95)dnl
2560894Sericdefine(`_SET_96_', 96)dnl
2663858Sericdefine(`_SET_97_', 97)dnl
2763858Sericdefine(`_SET_98_', 98)dnl')
2864010Sericifdef(`confSMTP_MAILER',, `define(`confSMTP_MAILER', `smtp')')dnl
2963998Sericifdef(`confLOCAL_MAILER',, `define(`confLOCAL_MAILER', `local')')dnl
3064010Sericifdef(`confRELAY_MAILER',,
3164010Seric	`define(`confRELAY_MAILER',
3264010Seric		`ifdef(`_MAILER_smtp_', `relay',
3364010Seric			`ifdef(`_MAILER_uucp', `suucp', `unknown')')')')dnl
3463998Sericdefine(`_SMTP_', `confSMTP_MAILER')dnl		for readability only
3563998Sericdefine(`_LOCAL_', `confLOCAL_MAILER')dnl	for readability only
3664010Sericdefine(`_RELAY_', `confRELAY_MAILER')dnl	for readability only
3752646Seric
3851222Seric##################
3951222Seric#   local info   #
4051222Seric##################
4151222Seric
4251889SericCwlocalhost
4351887Sericifdef(`USE_CW_FILE',
4451889Seric`# file containing names of hosts for which we receive email
4564033SericFw`'confCW_FILE',
4664033Seric	`dnl')
4764321Sericifdef(`confDOMAIN_NAME', `
4864321Seric# my official domain name
4964321SericDj`'confDOMAIN_NAME',
5064321Seric	`dnl')
5151222Seric
5264321Sericifdef(`_NULL_CLIENT_ONLY_',
5364321Seric`include(../m4/nullrelay.m4)m4exit',
5464321Seric	`dnl')
5564321Seric
5664321SericCP.
5764321Seric
5851222Sericifdef(`UUCP_RELAY',
5951222Seric`# UUCP relay host
6064033SericDY`'UUCP_RELAY
6160212SericCPUUCP
6257944Seric
6351222Seric')dnl
6451222Sericifdef(`BITNET_RELAY',
6551222Seric`#  BITNET relay host
6664033SericDB`'BITNET_RELAY
6760212SericCPBITNET
6857944Seric
6951222Seric')dnl
7051222Sericifdef(`CSNET_RELAY',
7151222Seric`# CSNET relay host
7264033SericDC`'CSNET_RELAY
7360212SericCPCSNET
7457944Seric
7551222Seric')dnl
7658364Sericifdef(`FAX_RELAY',
7758364Seric`# FAX relay host
7864033SericDF`'FAX_RELAY
7960212SericCPFAX
8058364Seric
8158364Seric')dnl
8264321Seric# "Smart" relay host (may be null)
8364321SericDS`'ifdef(`SMART_HOST', SMART_HOST)
8451222Seric
8558781Sericifdef(`MAILER_TABLE',
8658781Seric`# Mailer table (overriding domains)
8758781SericKmailertable MAILER_TABLE
8858781Seric
8958781Seric')dnl
9063754Sericifdef(`DOMAIN_TABLE',
9163754Seric`# Domain table (adding domains)
9263754SericKdomaintable DOMAIN_TABLE
9363754Seric
9463754Seric')dnl
9551222Seric# who I send unqualified names to (null means deliver locally)
9664033SericDR`'ifdef(`LOCAL_RELAY', LOCAL_RELAY)
9751222Seric
9857527Seric# who gets all local email traffic ($R has precedence for unqualified names)
9964033SericDH`'ifdef(`MAIL_HUB', MAIL_HUB)
10057527Seric
10158070Seric# who I masquerade as (can be $j)
10264033SericDM`'ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j)
10358070Seric
10457245Seric# class L: names that should be delivered locally, even if we have a relay
10557245Seric# class E: names that should be exposed as from this host, even if we masquerade
10651279SericCLroot
10757245SericCEroot
10851279Sericundivert(5)dnl
10951279Seric
11051222Seric# operators that cannot be in local usernames (i.e., network indicators)
11158288SericCO @ % ifdef(`_NO_UUCP_', `', `!')
11251222Seric
11351322Seric# a class with just dot (for identifying canonical names)
11451322SericC..
11551322Seric
11658808Sericifdef(`_OLD_SENDMAIL_', `dnl',
11758808Seric`# dequoting map
11858808SericKdequote dequote')
11957944Seric
12059033Sericundivert(6)dnl
12159033Seric
12257944Seric######################
12357944Seric#   Special macros   #
12457944Seric######################
12557944Seric
12657944Seric# SMTP initial login message
12764033SericDe`'confSMTP_LOGIN_MSG
12857944Seric
12957944Seric# UNIX initial From header format
13064033SericDl`'confFROM_LINE
13157944Seric
13257944Seric# my name for error messages
13364033SericDn`'confMAILER_NAME
13457944Seric
13557944Seric# delimiter (operator) characters
13664033SericDo`'confOPERATORS
13757944Seric
13857944Seric# format of a total name
13964033SericDq`'ifdef(`confFROM_HEADER', confFROM_HEADER,
14064251Seric	ifdef(`_OLD_SENDMAIL_', `$g$?x ($x)$.', `$?x$x <$g>$|$g$.'))
14157944Sericinclude(`../m4/version.m4')
14257944Seric
14357944Seric###############
14457944Seric#   Options   #
14557944Seric###############
14657944Seric
14759887Seric# strip message body to 7 bits on input?
14864033SericO7`'confSEVEN_BIT_INPUT
14957944Seric
15057944Seric# wait (in minutes) for alias file rebuild
15164033SericOa`'confALIAS_WAIT
15257944Seric
15357944Seric# location of alias file
15464033SericOA`'ifdef(`ALIAS_FILE', ALIAS_FILE, /etc/aliases)
15557944Seric
15658084Seric# minimum number of free blocks on filesystem
15764033SericOb`'confMIN_FREE_BLOCKS
15858084Seric
15957944Seric# substitution for space (blank) characters
16064033SericOB`'confBLANK_SUB
16157944Seric
16257944Seric# connect to "expensive" mailers on initial submission?
16364033SericOc`'confCON_EXPENSIVE
16457944Seric
16557944Seric# checkpoint queue runs after every N successful deliveries
16664033SericOC`'confCHECKPOINT_INTERVAL
16757944Seric
16857944Seric# default delivery mode
16964033SericOd`'confDELIVERY_MODE
17057944Seric
17157944Seric# automatically rebuild the alias database?
17264033SericOD`'confAUTO_REBUILD
17357944Seric
17464033Seric# error message header/file
17557944Sericifdef(`confERROR_MESSAGE',
17664033Seric	OE`'confERROR_MESSAGE,
17757944Seric	#OE/etc/sendmail.oE)
17857944Seric
17957944Seric# error mode
18057944Sericifdef(`confERROR_MODE',
18164033Seric	Oe`'confERROR_MODE,
18257944Seric	#Oep)
18357944Seric
18457944Seric# save Unix-style "From_" lines at top of header?
18564033SericOf`'confSAVE_FROM_LINES
18657944Seric
18757944Seric# temporary file mode
18864033SericOF`'confTEMP_FILE_MODE
18957944Seric
19057944Seric# match recipients against GECOS field?
19164033SericOG`'confMATCH_GECOS
19257944Seric
19357944Seric# default GID
19464033SericOg`'confDEF_GROUP_ID
19557944Seric
19657944Seric# maximum hop count
19764033SericOh`'confMAX_HOP
19857944Seric
19957944Seric# location of help file
20064033SericOH`'ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf)
20157944Seric
20257944Seric# ignore dots as terminators in incoming messages?
20364033SericOi`'confIGNORE_DOTS
20457944Seric
20557944Seric# Insist that the BIND name server be running to resolve names
20657944Sericifdef(`confBIND_OPTS',
20764033Seric	OI`'confBIND_OPTS,
20857944Seric	#OI)
20957944Seric
21059887Seric# deliver MIME-encapsulated error messages?
21164033SericOj`'confMIME_FORMAT_ERRORS
21259887Seric
21357944Seric# Forward file search path
21457944Sericifdef(`confFORWARD_PATH',
21564033Seric	OJ`'confFORWARD_PATH,
21657944Seric	#OJ/var/forward/$u:$z/.forward.$w:$z/.forward)
21757944Seric
21857944Seric# open connection cache size
21964033SericOk`'confMCI_CACHE_SIZE
22057944Seric
22157944Seric# open connection cache timeout
22264033SericOK`'confMCI_CACHE_TIMEOUT
22357944Seric
22461106Seric# use Errors-To: header?
22564033SericOl`'confUSE_ERRORS_TO
22661106Seric
22757944Seric# log level
22864033SericOL`'confLOG_LEVEL
22957944Seric
23057944Seric# send to me too, even in an alias expansion?
23164033SericOm`'confME_TOO
23257944Seric
23357944Seric# verify RHS in newaliases?
23464033SericOn`'confCHECK_ALIASES
23557944Seric
23657944Seric# default messages to old style headers if no special punctuation?
23764033SericOo`'confOLD_STYLE_HEADERS
23857944Seric
23958860Seric# SMTP daemon options
24058860Sericifdef(`confDAEMON_OPTIONS',
24164033Seric	OO`'confDAEMON_OPTIONS,
24258860Seric	#OOPort=esmtp)
24358860Seric
24458084Seric# privacy flags
24564033SericOp`'confPRIVACY_FLAGS
24658084Seric
24757944Seric# who (if anyone) should get extra copies of error messages
24857944Sericifdef(`confCOPY_ERRORS_TO',
24964033Seric	OP`'confCOPY_ERRORS_TO,
25057944Seric	#OPPostmaster)
25157944Seric
25257944Seric# slope of queue-only function
25357944Sericifdef(`confQUEUE_FACTOR',
25464033Seric	Oq`'confQUEUE_FACTOR,
25557944Seric	#Oq600000)
25657944Seric
25757944Seric# queue directory
25864033SericOQ`'ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue)
25957944Seric
26057944Seric# read timeout -- now OK per RFC 1123 section 5.3.2
26158119Sericifdef(`confREAD_TIMEOUT',
26264033Seric	Or`'confREAD_TIMEOUT,
26358119Seric	#Ordatablock=10m)
26457944Seric
26557944Seric# queue up everything before forking?
26664033SericOs`'confSAFE_QUEUE
26757944Seric
26857944Seric# status file
26964033SericOS`'ifdef(`STATUS_FILE', STATUS_FILE, /etc/sendmail.st)
27057944Seric
27157944Seric# default message timeout interval
27264033SericOT`'confMESSAGE_TIMEOUT
27357944Seric
27457944Seric# time zone handling:
27557944Seric#  if undefined, use system default
27657944Seric#  if defined but null, use TZ envariable passed in
27757944Seric#  if defined and non-null, use that info
27857944Sericifelse(confTIME_ZONE, `USE_SYSTEM', `#Ot',
27964341Seric	confTIME_ZONE, `USE_TZ', `Ot',
28064033Seric	`Ot`'confTIME_ZONE')
28157944Seric
28257944Seric# default UID
28364033SericOu`'confDEF_USER_ID
28457944Seric
28551887Seric# list of locations of user database file (null means no lookup)
28658720SericOU`'ifdef(`confUSERDB_SPEC', `confUSERDB_SPEC')
28751222Seric
28858860Seric# fallback MX host
28958860Sericifdef(`confFALLBACK_MX',
29064033Seric	OV`'confFALLBACK_MX,
29158860Seric	#OVfall.back.host.net)
29258860Seric
29363858Seric# if we are the best MX host for a site, try it directly instead of config err
29464033SericOw`'confTRY_NULL_MX_LIST
29563858Seric
29657944Seric# load average at which we just queue messages
29764033SericOx`'confQUEUE_LA
29857944Seric
29957944Seric# load average at which we refuse connections
30064033SericOX`'confREFUSE_LA
30157944Seric
30257944Seric# work recipient factor
30357944Sericifdef(`confWORK_RECIPIENT_FACTOR',
30464033Seric	Oy`'confWORK_RECIPIENT_FACTOR,
30557944Seric	#Oy30000)
30657944Seric
30757944Seric# deliver each queued job in a separate process?
30864033SericOY`'confSEPARATE_PROC
30957944Seric
31057944Seric# work class factor
31157944Sericifdef(`confWORK_CLASS_FACTOR',
31264033Seric	Oz`'confWORK_CLASS_FACTOR,
31357944Seric	#Oz1800)
31457944Seric
31557944Seric# work time factor
31657944Sericifdef(`confWORK_TIME_FACTOR',
31764033Seric	OZ`'confWORK_TIME_FACTOR,
31857944Seric	#OZ90000)
31957944Seric
32057944Seric###########################
32157944Seric#   Message precedences   #
32257944Seric###########################
32357944Seric
32457944SericPfirst-class=0
32557944SericPspecial-delivery=100
32658070SericPlist=-30
32757944SericPbulk=-60
32857944SericPjunk=-100
32957944Seric
33057944Seric#####################
33157944Seric#   Trusted users   #
33257944Seric#####################
33357944Seric
33457944SericTroot
33557944SericTdaemon
33657944SericTuucp
33757944Seric
33857944Seric#########################
33957944Seric#   Format of headers   #
34057944Seric#########################
34157944Seric
34258679SericH?P?Return-Path: $g
34364141SericHReceived: $?sfrom $s $.$?_($_) $.by $j ($v/$Z)$?r with $r$. id $i$?u for $u$.; $b
34457944SericH?D?Resent-Date: $a
34557944SericH?D?Date: $a
34657944SericH?F?Resent-From: $q
34757944SericH?F?From: $q
34857944SericH?x?Full-Name: $x
34957944SericHSubject:
35057944Seric# HPosted-Date: $a
35157944Seric# H?l?Received-Date: $b
35257944SericH?M?Resent-Message-Id: <$t.$i@$j>
35357944SericH?M?Message-Id: <$t.$i@$j>
35451222Seric#
35551222Seric######################################################################
35651222Seric######################################################################
35751222Seric#####
35851222Seric#####			REWRITING RULES
35951222Seric#####
36051222Seric######################################################################
36151222Seric######################################################################
36251222Seric
36358678Sericundivert(9)dnl
36451222Seric
36551222Seric###########################################
36651222Seric###  Rulset 3 -- Name Canonicalization  ###
36751222Seric###########################################
36851260SericS3
36951222Seric
370*64802Seric# handle null input (translate to <@> special case)
37158499SericR$@			$@ <@>
37258174Seric
37351222Seric# basic textual canonicalization -- note RFC733 heuristic here
37464144SericR$*<$*>$*<$*>$*		$2$3<$4>$5			strip multiple <> <>
37558158SericR$*<$*<$+>$*>$*		<$3>$5				2-level <> nesting
37658499SericR$*<>$*			$@ <@>				MAIL FROM:<> case
37751222SericR$*<$+>$*		$2				basic RFC821/822 parsing
37851222Seric
379*64802Seric# handle list:; syntax as special case
380*64802SericR$*:;$*			$@ $1 :; <@>
381*64802Seric
38251222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
38355416SericR@ $+ , $+		@ $1 : $2			change all "," to ":"
38451222Seric
38551222Seric# localize and dispose of route-based addresses
38660894SericR@ $+ : $+		$@ $>_SET_96_ < @$1 > : $2		handle <route-addr>
38751222Seric
38851222Seric# find focus for list syntax
38960894SericR $+ : $* ; @ $+	$@ $>_SET_96_ $1 : $2 ; < @ $3 >	list syntax
39055416SericR $+ : $* ;		$@ $1 : $2;			list syntax
39151222Seric
39251222Seric# find focus for @ syntax addresses
39355416SericR$+ @ $+		$: $1 < @ $2 >			focus on domain
39455416SericR$+ < $+ @ $+ >		$1 $2 < @ $3 >			move gaze right
39560894SericR$+ < @ $+ >		$@ $>_SET_96_ $1 < @ $2 >		already canonical
39651222Seric
39758288Sericifdef(`_NO_UUCP_', `dnl',
39858288Seric`# convert old-style addresses to a domain-based address
39960894SericR$- ! $+		$@ $>_SET_96_ $2 < @ $1 .UUCP >	resolve uucp names
40060894SericR$+ . $- ! $+		$@ $>_SET_96_ $3 < @ $1 . $2 >		domain uucps
40160894SericR$+ ! $+		$@ $>_SET_96_ $2 < @ $1 .UUCP >	uucp subdomains')
40251222Seric
40351222Seric# if we have % signs, take the rightmost one
40455416SericR$* % $*		$1 @ $2				First make them all @s.
40555416SericR$* @ $* @ $*		$1 % $2 @ $3			Undo all but the last.
40660894SericR$* @ $*		$@ $>_SET_96_ $1 < @ $2 >		Insert < > and finish
40751222Seric
40851222Seric# else we must be a local name
40951222Seric
41051222Seric
41160894Seric################################################
41260894Seric###  Ruleset _SET_96_ -- bottom half of ruleset 3  ###
41360894Seric################################################
41451222Seric
41557245Seric#  At this point, everything should be in a "local_part<@domain>extra" format.
41660894SericS`'_SET_96_
41751222Seric
41851222Seric# handle special cases for local names
41960262SericR$* < @ localhost > $*		$: $1 < @ $j . > $2		no domain at all
42060262SericR$* < @ localhost . $m > $*	$: $1 < @ $j . > $2		local domain
42160262Sericifdef(`_NO_UUCP_', `dnl',
42260262Seric`R$* < @ localhost . UUCP > $*	$: $1 < @ $j . > $2		.UUCP domain')
42364693SericR$* < @ [ $+ ] > $*		$: $1 < @ [[ $2 ]] > $3		catch [a.b.c.d]
42464693SericR$* < @ [ $=w ] > $*		$: $1 < @ $j . > $3		self-literal
42564693SericR$* < @ [[ $+ ]] > $*		$: $1 < @ [ $2 ] > $3		strip dbl [[]]
42663754Sericifdef(`DOMAIN_TABLE', `
42763754Seric# look up unqualified domains in the domain table
42863754SericR$* < @ $- > $*			$: $1 < @ $(domaintable $2 $) > $3',
42963754Seric`dnl')
43051889Sericundivert(2)dnl
43151222Seric
43259081Sericifdef(`_NO_UUCP_', `dnl',
43359081Seric`ifdef(`UUCP_RELAY',
43451274Seric`# pass UUCP addresses straight through
43555416SericR$* < @ $+ . UUCP > $*		$@ $1 < @ $2 . UUCP > $3',
43651274Seric`# if really UUCP, handle it immediately
43751322Sericifdef(`_CLASS_U_',
43855416Seric`R$* < @ $=U . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
43951322Sericifdef(`_CLASS_V_',
44055416Seric`R$* < @ $=V . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
44151322Sericifdef(`_CLASS_W_',
44255416Seric`R$* < @ $=W . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
44351322Sericifdef(`_CLASS_X_',
44455416Seric`R$* < @ $=X . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
44551322Sericifdef(`_CLASS_Y_',
44655416Seric`R$* < @ $=Y . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
44751267Seric
44851267Seric# try UUCP traffic as a local address
44955416SericR$* < @ $+ . UUCP > $*		$: $1 < @ $[ $2 $] . UUCP > $3
45051992Sericifdef(`_OLD_SENDMAIL_',
45155416Seric`R$* < @ $+ . $+ . UUCP > $*		$@ $1 < @ $2 . $3 . > $4',
45255416Seric`R$* < @ $+ . . UUCP > $*		$@ $1 < @ $2 . > $3')')
45359081Seric')
45461470Sericifdef(`_NO_CANONIFY_',
45561470Seric`# make sure local host names appear canonical
45661470SericR$* < @ $=w > $*		$: $1 < @ $2 . > $3',
45759081Seric`# pass to name server to make hostname canonical
45861470SericR$* < @ $* $~P > $*		$: $1 < @ $[ $2 $3 $] > $4')
45961470Seric
46051889Sericundivert(8)dnl
46151889Seric
46251322Seric# if this is the local hostname, make sure we treat is as canonical
46351322SericR$* < @ $j > $*			$: $1 < @ $j . > $2
46451222Seric
46551322Seric
46651222Seric##################################################
46751222Seric###  Ruleset 4 -- Final Output Post-rewriting  ###
46851222Seric##################################################
46951222SericS4
47051222Seric
47158499SericR$*<@>			$@ $1				handle <> and list:;
47251222Seric
47351222Seric# resolve numeric addresses to name if possible
47451322SericR$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	lookup numeric internet addr
47551222Seric
47651322Seric# strip trailing dot off possibly canonical name
47751322SericR$* < @ $+ . > $*	$1 < @ $2 > $3
47851322Seric
47951222Seric# externalize local domain info
48051322SericR$* < $+ > $*		$1 $2 $3			defocus
48151322SericR@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
48251997SericR@ $*			$@ @ $1				... and exit
48351222Seric
48458288Sericifdef(`_NO_UUCP_', `dnl',
48558288Seric`# UUCP must always be presented in old form
48658288SericR$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u')
48751222Seric
48851222Seric# delete duplicate local names
48951322SericR$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
49051222Seric
49151222Seric
49251222Seric
49360894Seric##############################################################
49460894Seric###   Ruleset _SET_97_ -- recanonicalize and call ruleset zero   ###
49560894Seric###		   (used for recursive calls)		   ###
49660894Seric##############################################################
49751222Seric
49860894SericS`'_SET_97_
49951222SericR$*			$: $>3 $1
50051222SericR$*			$@ $>0 $1
50151222Seric
50251222Seric
50351222Seric######################################
50451222Seric###   Ruleset 0 -- Parse Address   ###
50551222Seric######################################
50651222Seric
50751222SericS0
50851222Seric
50963998SericR<@>			$#_LOCAL_ $: <>			special case error msgs
51059887SericR$*:;<@>		$#error $@ USAGE $: "list:; syntax illegal for recipient addresses"
51158340Seric
51255416Sericifdef(`_MAILER_smtp_',
51355416Seric`# handle numeric address spec
51463860Sericifdef(`_NO_CANONIFY_', `dnl',
51563860Seric`R$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	numeric internet addr')
51663858SericR$* < @ [ $+ ] > $*	$: $>_SET_98_ $1 < @ [ $2 ] > $3	numeric internet spec
51763973SericR$* < @ [ $+ ] > $*	$#_SMTP_ $@ [$2] $: $1 @ [$2] $3	still numeric: send',
51863858Seric	`dnl')
51951222Seric
52051887Seric# now delete the local info -- note $=O to find characters that cause forwarding
52164321SericR$* < @ > $*		$@ $>_SET_97_ $1		user@ => user
52264321SericR< @ $=w . > : $*	$@ $>_SET_97_ $2		@here:... -> ...
52364321SericR$* $=O $* < @ $=w . >	$@ $>_SET_97_ $1 $2 $3		...@here -> ...
52463967Seric
52563967Seric# handle local hacks
52663967SericR$*			$: $>_SET_98_ $1
52758781Sericifdef(`MAILER_TABLE',
52858781Seric`
52958781Seric# try mailer table lookup
53060540SericR$* <@ $+ > $*		$: < $2 > $1 < @ $2 > $3	extract host name
53161106SericR< $+ . > $*		$: < $1 > $2			strip trailing dot
53262582SericR< $+ > $*		$: < $(mailertable $1 $) > $2	lookup
53361106SericR< $- : $+ > $*		$# $1 $@ $2 $: $3		check -- resolved?
53462582SericR< $+ > $*		$: $>90 <$1> $2			try domain',
53558781Seric`dnl')
53651222Seric
53751222Seric# short circuit local delivery so forwarded email works
53858516Sericifdef(`_LOCAL_NOT_STICKY_',
53963998Seric`R$=L < @ $=w . >		$#_LOCAL_ $: @ $1			special local names
54063998SericR$+ < @ $=w . >		$#_LOCAL_ $: $1			dispose directly',
54160894Seric`R$+ < @ $=w . >		$: $1 < @ $2 @ $H >		first try hub
54251992Sericifdef(`_OLD_SENDMAIL_',
54359635Seric`R$+ < $+ @ $-:$+ >	$# $3 $@ $4 $: $1 < $2 >	yep ....
54459635SericR$+ < $+ @ $+ >		$#relay $@ $3 $: $1 < $2 >	yep ....
54563998SericR$+ < $+ @ >		$#_LOCAL_ $: $1			nope, local address',
54663998Seric`R$+ < $+ @ $+ >		$#_LOCAL_ $: $1			yep ....
54763998SericR$+ < $+ @ >		$#_LOCAL_ $: @ $1			nope, local address')')
54851260Sericundivert(4)dnl
54951260Seric
55061468Sericifdef(`_NO_UUCP_', `dnl',
55161468Seric`# resolve remotely connected UUCP links (if any)
55251285Sericifdef(`_CLASS_V_',
55364719Seric`R$* < @ $=V . UUCP > $*		$: $>_SET_95_ < $V > $1 <@$2.UUCP> $3',
55452044Seric	`dnl')
55551285Sericifdef(`_CLASS_W_',
55664719Seric`R$* < @ $=W . UUCP > $*		$: $>_SET_95_ < $W > $1 <@$2.UUCP> $3',
55752044Seric	`dnl')
55851285Sericifdef(`_CLASS_X_',
55964719Seric`R$* < @ $=X . UUCP > $*		$: $>_SET_95_ < $X > $1 <@$2.UUCP> $3',
56061468Seric	`dnl')')
56151260Seric
56251222Seric# resolve fake top level domains by forwarding to other hosts
56351222Sericifdef(`BITNET_RELAY',
56464010Seric`R$*<@$+.BITNET>$*	$: $>_SET_95_ < $B > $1 <@$2.BITNET> $3	user@host.BITNET',
56551222Seric	`dnl')
56651222Sericifdef(`CSNET_RELAY',
56764010Seric`R$*<@$+.CSNET>$*	$: $>_SET_95_ < $C > $1 <@$2.CSNET> $3	user@host.CSNET',
56851222Seric	`dnl')
56958364Sericifdef(`_MAILER_fax_',
57063858Seric`R$+ < @ $+ .FAX >	$#fax $@ $2 $: $1		user@host.FAX',
57158364Seric`ifdef(`FAX_RELAY',
57264010Seric`R$*<@$+.FAX>$*		$: $>_SET_95_ < $F > $1 <@$2.FAX> $3	user@host.FAX',
57358364Seric	`dnl')')
57451222Seric
57551260Sericifdef(`UUCP_RELAY',
57651260Seric`# forward non-local UUCP traffic to our UUCP relay
57764719SericR$*<@$*.UUCP>$*		$: $>_SET_95_ < $Y > $1 @ <$2.UUCP> $3	uucp mail',
57855416Seric`ifdef(`_MAILER_uucp_',
57951260Seric`# forward other UUCP traffic straight to UUCP
58063858SericR< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $2		@host.UUCP:...
58163858SericR$+ < @ $+ .UUCP >	$#uucp $@ $2 $: $1		user@host.UUCP',
58251260Seric	`dnl')')
58363967Sericifdef(`_MAILER_usenet_', `
58463754Seric# addresses sent to net.group.USENET will get forwarded to a newsgroup
58563998SericR$+ . USENET		$#usenet $: $1',
58663860Seric	`dnl')
58763754Seric
58858070Sericifdef(`_LOCAL_RULES_',
58958070Seric`# figure out what should stay in our local mail system
59063754Sericundivert(1)', `dnl')
59163754Seric
59264321Seric# pass names that still have a host to a smarthost (if defined)
59364010SericR$* < @ $* > $*		$: $>_SET_95_ < $S > $1 < @ $2 > $3	glue on smarthost name
59463754Seric
59564321Seric# deal with other remote names
59663946Sericifdef(`_MAILER_smtp_',
59763973Seric`R$* < @$* > $*		$#_SMTP_ $@ $2 $: $1 < @ $2 > $3		user@host.domain',
59864321Seric`R$* < @$* > $*		$#error $@NOHOST $: Unrecognized host name $2')
59951222Seric
60051992Sericifdef(`_OLD_SENDMAIL_',
60151887Seric`# forward remaining names to local relay, if any
60263998SericR$=L			$#_LOCAL_ $: $1			special local names
60364010SericR$+			$: $>_SET_95_ < $R > $1			try relay
60464010SericR$+			$: $>_SET_95_ < $H > $1			try hub
60564010SericR$+			$#_LOCAL_ $: $1			no relay or hub: local',
60658811Seric
60758811Seric`# if this is quoted, strip the quotes and try again
60858811SericR$+			$: $(dequote $1 $)		strip quotes
60964502SericR$+ $=O $+		$@ $>_SET_97_ $1 $2 $3			try again
61058811Seric
61158811Seric# handle locally delivered names
61263998SericR$=L			$#_LOCAL_ $: @ $1			special local names
61363998SericR$+			$#_LOCAL_ $: $1			regular local names
61451222Seric
61555416Seric###########################################################################
61655416Seric###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
61755416Seric###		   (new sendmail only)					###
61855416Seric###########################################################################
61951222Seric
62051322SericS5
62151322Seric
62258808Seric# see if we have a relay or a hub
62364010SericR$+			$: $>_SET_95_ < $R > $1			try relay
62464010SericR$+			$: $>_SET_95_ < $H > $1			try hub')
62560540Sericifdef(`MAILER_TABLE',
62660540Seric`
62760540Seric
62863858Seric###################################################################
62963858Seric###  Ruleset 90 -- try domain part of mailertable entry 	###
63063858Seric###		   (new sendmail only)				###
63163858Seric###################################################################
63260540Seric
63360540SericS90
63464010SericR<$- . $+ > $*		$: < $(mailertable .$2 $@ $1 $) > $3	lookup
63560540SericR<$- : $+ > $*		$# $1 $@ $2 $: $3		check -- resolved?
63662372SericR< . $+ > $*		$@ $>90 <$1> $2			no -- strip & try again
63760540SericR<$*> $*		$@ $2				no match',
63860540Seric`dnl')
63963858Seric
64063858Seric###################################################################
64164010Seric###  Ruleset _SET_95_ -- canonify mailer:host syntax to triple	###
64264010Seric###################################################################
64364010Seric
64464010SericS`'_SET_95_
64564010SericR< > $*			$@ $1				strip off null relay
64664010SericR< $- : $+ > $*		$# $1 $@ $2 $: $3		try qualified mailer
64764010SericR< $=w > $*		$@ $2				delete local host
64864010SericR< $+ > $*		$#_RELAY_ $@ $1 $: $2		use unqualified mailer
64964010Seric
65064010Seric###################################################################
65163858Seric###  Ruleset _SET_98_ -- local part of ruleset zero (can be null)	###
65263858Seric###################################################################
65363858Seric
65463858SericS`'_SET_98_
65563858Sericundivert(3)dnl
65651222Seric#
65751222Seric######################################################################
65851222Seric######################################################################
65951222Seric#####
66056790Seric`#####			MAILER DEFINITIONS'
66151222Seric#####
66251222Seric######################################################################
66351222Seric######################################################################
66451222Sericundivert(7)dnl
665