xref: /original-bsd/usr.sbin/sendmail/cf/m4/proto.m4 (revision b501d107)
16f4c5567Sericdivert(-1)
26f4c5567Seric#
36f4c5567Seric# Copyright (c) 1983 Eric P. Allman
494a19095Sbostic# Copyright (c) 1988, 1993
594a19095Sbostic#	The Regents of the University of California.  All rights reserved.
66f4c5567Seric#
76f4c5567Seric# %sccs.include.redist.sh%
86f4c5567Seric#
96f4c5567Sericdivert(0)
106f4c5567Seric
11*b501d107SericVERSIONID(`@(#)proto.m4	8.5 (Berkeley) 07/20/93')
126f4c5567Seric
1363eeb308SericMAILER(local)dnl
146f4c5567Seric
15585ddacfSericifdef(`_OLD_SENDMAIL_',
16585ddacfSeric`define(`_SET_96_', 6)dnl
1711f06b84Sericdefine(`_SET_97_', 7)dnl
1811f06b84Sericdefine(`_SET_98_', 8)dnl',
192635e5f8Seric`# level 4 config file format
20585ddacfSericV4
21585ddacfSericdefine(`_SET_96_', 96)dnl
2211f06b84Sericdefine(`_SET_97_', 97)dnl
2311f06b84Sericdefine(`_SET_98_', 98)dnl')
24472f2a37Seric
256f4c5567Seric##################
266f4c5567Seric#   local info   #
276f4c5567Seric##################
286f4c5567Seric
29a8d79e3dSericCP.
30a8d79e3dSeric
3131695942SericCwlocalhost
32b1286b66Sericifdef(`USE_CW_FILE',
3331695942Seric`# file containing names of hosts for which we receive email
340bf9a1dbSericCONCAT(`Fw', confCW_FILE)', `dnl')
356f4c5567Seric
366f4c5567Sericifdef(`UUCP_RELAY',
376f4c5567Seric`# UUCP relay host
3813c6b009SericCONCAT(DY, UUCP_RELAY)
39a8d79e3dSericCPUUCP
400fc742e1Seric
416f4c5567Seric')dnl
426f4c5567Sericifdef(`BITNET_RELAY',
436f4c5567Seric`#  BITNET relay host
446f4c5567SericCONCAT(DB, BITNET_RELAY)
45a8d79e3dSericCPBITNET
460fc742e1Seric
476f4c5567Seric')dnl
486f4c5567Sericifdef(`CSNET_RELAY',
496f4c5567Seric`# CSNET relay host
506f4c5567SericCONCAT(DC, CSNET_RELAY)
51a8d79e3dSericCPCSNET
520fc742e1Seric
536f4c5567Seric')dnl
545caa7271Sericifdef(`FAX_RELAY',
555caa7271Seric`# FAX relay host
565caa7271SericCONCAT(DF, FAX_RELAY)
57a8d79e3dSericCPFAX
585caa7271Seric
595caa7271Seric')dnl
6085afb57eSericifdef(`SMART_HOST',
6185afb57eSeric`# "Smart" UUCP relay host
6285afb57eSericCONCAT(DS, SMART_HOST)
636f4c5567Seric
6485afb57eSeric')dnl
653be47185Sericifdef(`MAILER_TABLE',
663be47185Seric`# Mailer table (overriding domains)
673be47185SericKmailertable MAILER_TABLE
683be47185Seric
693be47185Seric')dnl
70f6f96ca7Sericifdef(`DOMAIN_TABLE',
71f6f96ca7Seric`# Domain table (adding domains)
72f6f96ca7SericKdomaintable DOMAIN_TABLE
73f6f96ca7Seric
74f6f96ca7Seric')dnl
756f4c5567Seric# who I send unqualified names to (null means deliver locally)
766f4c5567SericCONCAT(DR, ifdef(`LOCAL_RELAY', LOCAL_RELAY))
776f4c5567Seric
78525ff8d9Seric# who gets all local email traffic ($R has precedence for unqualified names)
79525ff8d9SericCONCAT(DH, ifdef(`MAIL_HUB', MAIL_HUB))
80525ff8d9Seric
8185afb57eSeric# my official hostname ($w or $w.$D)
8285afb57eSericCONCAT(Dj$w, ifdef(`NEED_DOMAIN', .$D))
8385afb57eSeric
8485afb57eSeric# who I masquerade as (can be $j)
8585afb57eSericCONCAT(DM, ifdef(`MASQUERADE_NAME', MASQUERADE_NAME, $j))
8685afb57eSeric
8782027dd5Seric# class L: names that should be delivered locally, even if we have a relay
8882027dd5Seric# class E: names that should be exposed as from this host, even if we masquerade
8971dc253dSericCLroot
9082027dd5SericCEroot
9171dc253dSericundivert(5)dnl
9271dc253dSeric
936f4c5567Seric# operators that cannot be in local usernames (i.e., network indicators)
9490caf1e3SericCO @ % ifdef(`_NO_UUCP_', `', `!')
956f4c5567Seric
9663eeb308Seric# a class with just dot (for identifying canonical names)
9763eeb308SericC..
9863eeb308Seric
99fdf362d5Sericifdef(`_OLD_SENDMAIL_', `dnl',
100fdf362d5Seric`# dequoting map
101fdf362d5SericKdequote dequote')
1026f4c5567Seric
10316748008Sericundivert(6)dnl
10416748008Seric
1050fc742e1Seric######################
1060fc742e1Seric#   Special macros   #
1070fc742e1Seric######################
1086f4c5567Seric
1090fc742e1Seric# SMTP initial login message
1100fc742e1SericCONCAT(De, confSMTP_LOGIN_MSG)
1110fc742e1Seric
1120fc742e1Seric# UNIX initial From header format
1130fc742e1SericCONCAT(Dl, confFROM_LINE)
1140fc742e1Seric
1150fc742e1Seric# my name for error messages
1160fc742e1SericCONCAT(Dn, confMAILER_NAME)
1170fc742e1Seric
1180fc742e1Seric# delimiter (operator) characters
1190fc742e1SericCONCAT(Do, confOPERATORS)
1200fc742e1Seric
1210fc742e1Seric# format of a total name
1220fc742e1SericCONCAT(Dq, ifdef(`confFROM_HEADER', confFROM_HEADER,
1230fc742e1Seric	ifdef(`_OLD_SENDMAIL_', `$g$?x ($x)$.', `$?x$x <$g>$|$g$.')))
1246f4c5567Sericinclude(`../m4/version.m4')
1250fc742e1Seric
1260fc742e1Seric###############
1270fc742e1Seric#   Options   #
1280fc742e1Seric###############
1290fc742e1Seric
13070de6e01Seric# strip message body to 7 bits on input?
13170de6e01SericCONCAT(O7, confSEVEN_BIT_INPUT)
1320fc742e1Seric
1330fc742e1Seric# wait (in minutes) for alias file rebuild
1340fc742e1SericCONCAT(Oa, confALIAS_WAIT)
1350fc742e1Seric
1360fc742e1Seric# location of alias file
1370fc742e1SericCONCAT(OA, ifdef(`ALIAS_FILE', ALIAS_FILE, /etc/aliases))
1380fc742e1Seric
1392188aa70Seric# minimum number of free blocks on filesystem
1402188aa70SericCONCAT(Ob, confMIN_FREE_BLOCKS)
1412188aa70Seric
1420fc742e1Seric# substitution for space (blank) characters
1430fc742e1SericCONCAT(OB, confBLANK_SUB)
1440fc742e1Seric
1450fc742e1Seric# connect to "expensive" mailers on initial submission?
1460fc742e1SericCONCAT(Oc, confCON_EXPENSIVE)
1470fc742e1Seric
1480fc742e1Seric# checkpoint queue runs after every N successful deliveries
1490fc742e1SericCONCAT(OC, confCHECKPOINT_INTERVAL)
1500fc742e1Seric
1510fc742e1Seric# default delivery mode
1520fc742e1SericCONCAT(Od, confDELIVERY_MODE)
1530fc742e1Seric
1540fc742e1Seric# automatically rebuild the alias database?
1550fc742e1SericCONCAT(OD, confAUTO_REBUILD)
1560fc742e1Seric
1570fc742e1Seric# error message header/file */
1580fc742e1Sericifdef(`confERROR_MESSAGE',
159e54d09e1Seric	CONCAT(OE, confERROR_MESSAGE),
1600fc742e1Seric	#OE/etc/sendmail.oE)
1610fc742e1Seric
1620fc742e1Seric# error mode
1630fc742e1Sericifdef(`confERROR_MODE',
164e54d09e1Seric	CONCAT(Oe, confERROR_MODE),
1650fc742e1Seric	#Oep)
1660fc742e1Seric
1670fc742e1Seric# save Unix-style "From_" lines at top of header?
1680fc742e1SericCONCAT(Of, confSAVE_FROM_LINES)
1690fc742e1Seric
1700fc742e1Seric# temporary file mode
1710fc742e1SericCONCAT(OF, confTEMP_FILE_MODE)
1720fc742e1Seric
1730fc742e1Seric# match recipients against GECOS field?
1740fc742e1SericCONCAT(OG, confMATCH_GECOS)
1750fc742e1Seric
1760fc742e1Seric# default GID
1770fc742e1SericCONCAT(Og, confDEF_GROUP_ID)
1780fc742e1Seric
1790fc742e1Seric# maximum hop count
1800fc742e1SericCONCAT(Oh, confMAX_HOP)
1810fc742e1Seric
1820fc742e1Seric# location of help file
1830fc742e1SericCONCAT(OH, ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf))
1840fc742e1Seric
1850fc742e1Seric# ignore dots as terminators in incoming messages?
1860fc742e1SericCONCAT(Oi, confIGNORE_DOTS)
1870fc742e1Seric
1880fc742e1Seric# Insist that the BIND name server be running to resolve names
1890fc742e1Sericifdef(`confBIND_OPTS',
1900fc742e1Seric	CONCAT(OI, confBIND_OPTS),
1910fc742e1Seric	#OI)
1920fc742e1Seric
19370de6e01Seric# deliver MIME-encapsulated error messages?
19470de6e01SericCONCAT(Oj, confMIME_FORMAT_ERRORS)
19570de6e01Seric
1960fc742e1Seric# Forward file search path
1970fc742e1Sericifdef(`confFORWARD_PATH',
1980fc742e1Seric	CONCAT(OJ, confFORWARD_PATH),
1990fc742e1Seric	#OJ/var/forward/$u:$z/.forward.$w:$z/.forward)
2000fc742e1Seric
2010fc742e1Seric# open connection cache size
2020fc742e1SericCONCAT(Ok, confMCI_CACHE_SIZE)
2030fc742e1Seric
2040fc742e1Seric# open connection cache timeout
2050fc742e1SericCONCAT(OK, confMCI_CACHE_TIMEOUT)
2060fc742e1Seric
207bd6adeb9Seric# use Errors-To: header?
208bd6adeb9SericCONCAT(Ol, confUSE_ERRORS_TO)
209bd6adeb9Seric
2100fc742e1Seric# log level
2110fc742e1SericCONCAT(OL, confLOG_LEVEL)
2120fc742e1Seric
2130fc742e1Seric# send to me too, even in an alias expansion?
2140fc742e1SericCONCAT(Om, confME_TOO)
2150fc742e1Seric
2160fc742e1Seric# verify RHS in newaliases?
2170fc742e1SericCONCAT(On, confCHECK_ALIASES)
2180fc742e1Seric
2190fc742e1Seric# default messages to old style headers if no special punctuation?
2200fc742e1SericCONCAT(Oo, confOLD_STYLE_HEADERS)
2210fc742e1Seric
2228bcc474dSeric# SMTP daemon options
2238bcc474dSericifdef(`confDAEMON_OPTIONS',
2248bcc474dSeric	CONCAT(OO, confDAEMON_OPTIONS),
2258bcc474dSeric	#OOPort=esmtp)
2268bcc474dSeric
2272188aa70Seric# privacy flags
2282188aa70SericCONCAT(Op, confPRIVACY_FLAGS)
2292188aa70Seric
2300fc742e1Seric# who (if anyone) should get extra copies of error messages
2310fc742e1Sericifdef(`confCOPY_ERRORS_TO',
2320fc742e1Seric	CONCAT(OP, confCOPY_ERRORS_TO),
2330fc742e1Seric	#OPPostmaster)
2340fc742e1Seric
2350fc742e1Seric# slope of queue-only function
2360fc742e1Sericifdef(`confQUEUE_FACTOR',
2370fc742e1Seric	CONCAT(Oq, confQUEUE_FACTOR),
2380fc742e1Seric	#Oq600000)
2390fc742e1Seric
2400fc742e1Seric# queue directory
2410fc742e1SericCONCAT(OQ, ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue))
2420fc742e1Seric
2430fc742e1Seric# read timeout -- now OK per RFC 1123 section 5.3.2
2442635e5f8Sericifdef(`confREAD_TIMEOUT',
2452635e5f8Seric	CONCAT(Or, confREAD_TIMEOUT),
2462635e5f8Seric	#Ordatablock=10m)
2470fc742e1Seric
2480fc742e1Seric# queue up everything before forking?
2490fc742e1SericCONCAT(Os, confSAFE_QUEUE)
2500fc742e1Seric
2510fc742e1Seric# status file
2520fc742e1SericCONCAT(OS, ifdef(`STATUS_FILE', STATUS_FILE, /etc/sendmail.st))
2530fc742e1Seric
2540fc742e1Seric# default message timeout interval
2550fc742e1SericCONCAT(OT, confMESSAGE_TIMEOUT)
2560fc742e1Seric
2570fc742e1Seric# time zone handling:
2580fc742e1Seric#  if undefined, use system default
2590fc742e1Seric#  if defined but null, use TZ envariable passed in
2600fc742e1Seric#  if defined and non-null, use that info
2610fc742e1Sericifelse(confTIME_ZONE, `USE_SYSTEM', `#Ot',
2620fc742e1Seric	confTIME_ZONE, `USE_TZ', `',
2630fc742e1Seric	`CONCAT(Ot, confTIME_ZONE)')
2640fc742e1Seric
2650fc742e1Seric# default UID
2660fc742e1SericCONCAT(Ou, confDEF_USER_ID)
2670fc742e1Seric
2680fc742e1Seric# list of locations of user database file (null means no lookup)
269b1ca68b5SericOU`'ifdef(`confUSERDB_SPEC', `confUSERDB_SPEC')
2700fc742e1Seric
2718bcc474dSeric# fallback MX host
2728bcc474dSericifdef(`confFALLBACK_MX',
2738bcc474dSeric	CONCAT(OV, confFALLBACK_MX),
2748bcc474dSeric	#OVfall.back.host.net)
2758bcc474dSeric
27611f06b84Seric# if we are the best MX host for a site, try it directly instead of config err
27711f06b84SericCONCAT(Ow, confTRY_NULL_MX_LIST)
27811f06b84Seric
2790fc742e1Seric# load average at which we just queue messages
2800fc742e1SericCONCAT(Ox, confQUEUE_LA)
2810fc742e1Seric
2820fc742e1Seric# load average at which we refuse connections
2830fc742e1SericCONCAT(OX, confREFUSE_LA)
2840fc742e1Seric
2850fc742e1Seric# work recipient factor
2860fc742e1Sericifdef(`confWORK_RECIPIENT_FACTOR',
2870fc742e1Seric	CONCAT(Oy, confWORK_RECIPIENT_FACTOR),
2880fc742e1Seric	#Oy30000)
2890fc742e1Seric
2900fc742e1Seric# deliver each queued job in a separate process?
2910fc742e1SericCONCAT(OY, confSEPARATE_PROC)
2920fc742e1Seric
2930fc742e1Seric# work class factor
2940fc742e1Sericifdef(`confWORK_CLASS_FACTOR',
2950fc742e1Seric	CONCAT(Oz, confWORK_CLASS_FACTOR),
2960fc742e1Seric	#Oz1800)
2970fc742e1Seric
2980fc742e1Seric# work time factor
2990fc742e1Sericifdef(`confWORK_TIME_FACTOR',
3000fc742e1Seric	CONCAT(OZ, confWORK_TIME_FACTOR),
3010fc742e1Seric	#OZ90000)
3020fc742e1Seric
3030fc742e1Seric###########################
3040fc742e1Seric#   Message precedences   #
3050fc742e1Seric###########################
3060fc742e1Seric
3070fc742e1SericPfirst-class=0
3080fc742e1SericPspecial-delivery=100
30985afb57eSericPlist=-30
3100fc742e1SericPbulk=-60
3110fc742e1SericPjunk=-100
3120fc742e1Seric
3130fc742e1Seric#####################
3140fc742e1Seric#   Trusted users   #
3150fc742e1Seric#####################
3160fc742e1Seric
3170fc742e1SericTroot
3180fc742e1SericTdaemon
3190fc742e1SericTuucp
3200fc742e1Seric
3210fc742e1Seric#########################
3220fc742e1Seric#   Format of headers   #
3230fc742e1Seric#########################
3240fc742e1Seric
325d5ba2395SericH?P?Return-Path: $g
326585ddacfSericHReceived: $?sfrom $s $.$?_($_) $.by $j ($v/$Z)$?r with $r$. id $i; $b
3270fc742e1SericH?D?Resent-Date: $a
3280fc742e1SericH?D?Date: $a
3290fc742e1SericH?F?Resent-From: $q
3300fc742e1SericH?F?From: $q
3310fc742e1SericH?x?Full-Name: $x
3320fc742e1SericHSubject:
3330fc742e1Seric# HPosted-Date: $a
3340fc742e1Seric# H?l?Received-Date: $b
3350fc742e1SericH?M?Resent-Message-Id: <$t.$i@$j>
3360fc742e1SericH?M?Message-Id: <$t.$i@$j>
3376f4c5567Seric#
3386f4c5567Seric######################################################################
3396f4c5567Seric######################################################################
3406f4c5567Seric#####
3416f4c5567Seric#####			REWRITING RULES
3426f4c5567Seric#####
3436f4c5567Seric######################################################################
3446f4c5567Seric######################################################################
3456f4c5567Seric
3468d35298dSericundivert(9)dnl
3476f4c5567Seric
3486f4c5567Seric###########################################
3496f4c5567Seric###  Rulset 3 -- Name Canonicalization  ###
3506f4c5567Seric###########################################
35171e1a4d1SericS3
3526f4c5567Seric
3531c0b669eSeric# handle null input and list syntax (translate to <@> special case)
3541c0b669eSericR$@			$@ <@>
35541afd8b4SericR$*:;$*			$@ $1 :; <@>
356f2ad5decSeric
3576f4c5567Seric# basic textual canonicalization -- note RFC733 heuristic here
3587b2c0d8dSericR$*<$*>$*<$*>$*		<$2>$3$4$5			strip multiple <> <>
35985ebc819SericR$*<$*<$+>$*>$*		<$3>$5				2-level <> nesting
3601c0b669eSericR$*<>$*			$@ <@>				MAIL FROM:<> case
3616f4c5567SericR$*<$+>$*		$2				basic RFC821/822 parsing
3626f4c5567Seric
3636f4c5567Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
3646f4c5567SericR@ $+ , $+		@ $1 : $2			change all "," to ":"
3656f4c5567Seric
3666f4c5567Seric# localize and dispose of route-based addresses
367585ddacfSericR@ $+ : $+		$@ $>_SET_96_ < @$1 > : $2		handle <route-addr>
3686f4c5567Seric
3696f4c5567Seric# find focus for list syntax
370585ddacfSericR $+ : $* ; @ $+	$@ $>_SET_96_ $1 : $2 ; < @ $3 >	list syntax
3716f4c5567SericR $+ : $* ;		$@ $1 : $2;			list syntax
3726f4c5567Seric
3736f4c5567Seric# find focus for @ syntax addresses
3746f4c5567SericR$+ @ $+		$: $1 < @ $2 >			focus on domain
3756f4c5567SericR$+ < $+ @ $+ >		$1 $2 < @ $3 >			move gaze right
376585ddacfSericR$+ < @ $+ >		$@ $>_SET_96_ $1 < @ $2 >		already canonical
3776f4c5567Seric
37890caf1e3Sericifdef(`_NO_UUCP_', `dnl',
37990caf1e3Seric`# convert old-style addresses to a domain-based address
380585ddacfSericR$- ! $+		$@ $>_SET_96_ $2 < @ $1 .UUCP >	resolve uucp names
381585ddacfSericR$+ . $- ! $+		$@ $>_SET_96_ $3 < @ $1 . $2 >		domain uucps
382585ddacfSericR$+ ! $+		$@ $>_SET_96_ $2 < @ $1 .UUCP >	uucp subdomains')
3836f4c5567Seric
3846f4c5567Seric# if we have % signs, take the rightmost one
3856f4c5567SericR$* % $*		$1 @ $2				First make them all @s.
3866f4c5567SericR$* @ $* @ $*		$1 % $2 @ $3			Undo all but the last.
387585ddacfSericR$* @ $*		$@ $>_SET_96_ $1 < @ $2 >		Insert < > and finish
3886f4c5567Seric
3896f4c5567Seric# else we must be a local name
3906f4c5567Seric
3916f4c5567Seric
392585ddacfSeric################################################
393585ddacfSeric###  Ruleset _SET_96_ -- bottom half of ruleset 3  ###
394585ddacfSeric################################################
3956f4c5567Seric
39682027dd5Seric#  At this point, everything should be in a "local_part<@domain>extra" format.
397585ddacfSericS`'_SET_96_
3986f4c5567Seric
3996f4c5567Seric# handle special cases for local names
400fde20765SericR$* < @ localhost > $*		$: $1 < @ $j . > $2		no domain at all
401fde20765SericR$* < @ localhost . $m > $*	$: $1 < @ $j . > $2		local domain
402fde20765Sericifdef(`_NO_UUCP_', `dnl',
403fde20765Seric`R$* < @ localhost . UUCP > $*	$: $1 < @ $j . > $2		.UUCP domain')
404f6f96ca7Sericifdef(`DOMAIN_TABLE', `
405f6f96ca7Seric# look up unqualified domains in the domain table
406f6f96ca7SericR$* < @ $- > $*			$: $1 < @ $(domaintable $2 $) > $3',
407f6f96ca7Seric`dnl')
40831695942Sericundivert(2)dnl
4096f4c5567Seric
41060f3bdf6Sericifdef(`_NO_UUCP_', `dnl',
41160f3bdf6Seric`ifdef(`UUCP_RELAY',
412788179f5Seric`# pass UUCP addresses straight through
413788179f5SericR$* < @ $+ . UUCP > $*		$@ $1 < @ $2 . UUCP > $3',
414788179f5Seric`# if really UUCP, handle it immediately
41563eeb308Sericifdef(`_CLASS_U_',
41663eeb308Seric`R$* < @ $=U . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
41763eeb308Sericifdef(`_CLASS_V_',
41863eeb308Seric`R$* < @ $=V . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
41963eeb308Sericifdef(`_CLASS_W_',
42063eeb308Seric`R$* < @ $=W . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
42163eeb308Sericifdef(`_CLASS_X_',
42263eeb308Seric`R$* < @ $=X . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
42363eeb308Sericifdef(`_CLASS_Y_',
42463eeb308Seric`R$* < @ $=Y . UUCP > $*	$@ $1 < @ $2 . UUCP > $3', `dnl')
425a027f997Seric
426a027f997Seric# try UUCP traffic as a local address
42763eeb308SericR$* < @ $+ . UUCP > $*		$: $1 < @ $[ $2 $] . UUCP > $3
4284588ece0Sericifdef(`_OLD_SENDMAIL_',
4294cad3747Seric`R$* < @ $+ . $+ . UUCP > $*		$@ $1 < @ $2 . $3 . > $4',
43097777037Seric`R$* < @ $+ . . UUCP > $*		$@ $1 < @ $2 . > $3')')
43160f3bdf6Seric')
4322f61eeb4Sericifdef(`_NO_CANONIFY_',
4332f61eeb4Seric`# make sure local host names appear canonical
4342f61eeb4SericR$* < @ $=w > $*		$: $1 < @ $2 . > $3',
43560f3bdf6Seric`# pass to name server to make hostname canonical
4362f61eeb4SericR$* < @ $* $~P > $*		$: $1 < @ $[ $2 $3 $] > $4')
4372f61eeb4Seric
43831695942Sericundivert(8)dnl
43931695942Seric
44063eeb308Seric# if this is the local hostname, make sure we treat is as canonical
44163eeb308SericR$* < @ $j > $*			$: $1 < @ $j . > $2
4426f4c5567Seric
4436f4c5567Seric
4446f4c5567Seric##################################################
4456f4c5567Seric###  Ruleset 4 -- Final Output Post-rewriting  ###
4466f4c5567Seric##################################################
4476f4c5567SericS4
4486f4c5567Seric
4491c0b669eSericR$*<@>			$@ $1				handle <> and list:;
4506f4c5567Seric
4516f4c5567Seric# resolve numeric addresses to name if possible
4526f4c5567SericR$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	lookup numeric internet addr
4536f4c5567Seric
45463eeb308Seric# strip trailing dot off possibly canonical name
45563eeb308SericR$* < @ $+ . > $*	$1 < @ $2 > $3
45663eeb308Seric
4576f4c5567Seric# externalize local domain info
4586f4c5567SericR$* < $+ > $*		$1 $2 $3			defocus
4596f4c5567SericR@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
4601f23b499SericR@ $*			$@ @ $1				... and exit
4616f4c5567Seric
46290caf1e3Sericifdef(`_NO_UUCP_', `dnl',
46390caf1e3Seric`# UUCP must always be presented in old form
46490caf1e3SericR$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u')
4656f4c5567Seric
4666f4c5567Seric# delete duplicate local names
467b47d0647SericR$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
4686f4c5567Seric
4696f4c5567Seric
4706f4c5567Seric
471585ddacfSeric##############################################################
472585ddacfSeric###   Ruleset _SET_97_ -- recanonicalize and call ruleset zero   ###
4736f4c5567Seric###		   (used for recursive calls)		   ###
474585ddacfSeric##############################################################
4756f4c5567Seric
476585ddacfSericS`'_SET_97_
4776f4c5567SericR$*			$: $>3 $1
4786f4c5567SericR$*			$@ $>0 $1
4796f4c5567Seric
4806f4c5567Seric
4816f4c5567Seric######################################
4826f4c5567Seric###   Ruleset 0 -- Parse Address   ###
4836f4c5567Seric######################################
4846f4c5567Seric
4856f4c5567SericS0
4866f4c5567Seric
4873d995905SericR<@>			$#local $: <>			special case error msgs
48870de6e01SericR$*:;<@>		$#error $@ USAGE $: "list:; syntax illegal for recipient addresses"
4891c5e29abSeric
4904cad3747Sericifdef(`_MAILER_smtp_',
4914cad3747Seric`# handle numeric address spec
4928e0508d4Sericifdef(`_NO_CANONIFY_', `dnl',
4938e0508d4Seric`R$* < @ [ $+ ] > $*	$: $1 < @ $[ [$2] $] > $3	numeric internet addr')
49411f06b84SericR$* < @ [ $+ ] > $*	$: $>_SET_98_ $1 < @ [ $2 ] > $3	numeric internet spec
49511f06b84SericR$* < @ [ $+ ] > $*	$#smtp $@ [$2] $: $1 @ [$2] $3	still numeric: send',
4963c5c069fSeric	`dnl')
4976f4c5567Seric
498b1286b66Seric# now delete the local info -- note $=O to find characters that cause forwarding
499585ddacfSericR$* < @ > $*		$@ $>_SET_97_ $1			user@ => user
500585ddacfSericR< @ $=w . > : $*	$@ $>_SET_97_ $2			@here:... -> ...
501585ddacfSericR$* $=O $* < @ $=w . >	$@ $>_SET_97_ $1 $2 $3			...@here -> ...
5023be47185Sericifdef(`MAILER_TABLE',
5033be47185Seric`
5043be47185Seric# try mailer table lookup
505bc926da7SericR$* <@ $+ > $*		$: < $2 > $1 < @ $2 > $3	extract host name
506bc926da7SericR< $+ . > $*		$: < $1 > $2			strip trailing dot
5073fb97881SericR< $+ > $*		$: < $(mailertable $1 $) > $2	lookup
508bc926da7SericR< $- : $+ > $*		$# $1 $@ $2 $: $3		check -- resolved?
5093fb97881SericR< $+ > $*		$: $>90 <$1> $2			try domain',
5103be47185Seric`dnl')
5116f4c5567Seric
5126f4c5567Seric# short circuit local delivery so forwarded email works
513c4cdc003Sericifdef(`_LOCAL_NOT_STICKY_',
514585ddacfSeric`R$=L < @ $=w . >		$#local $: @ $1			special local names
515585ddacfSericR$+ < @ $=w . >		$#local $: $1			dispose directly',
516585ddacfSeric`R$+ < @ $=w . >		$: $1 < @ $2 @ $H >		first try hub
5174588ece0Sericifdef(`_OLD_SENDMAIL_',
518c3d0eb4bSeric`R$+ < $+ @ $-:$+ >	$# $3 $@ $4 $: $1 < $2 >	yep ....
519c3d0eb4bSericR$+ < $+ @ $+ >		$#relay $@ $3 $: $1 < $2 >	yep ....
520525ff8d9SericR$+ < $+ @ >		$#local $: $1			nope, local address',
521525ff8d9Seric`R$+ < $+ @ $+ >		$#local $: $1			yep ....
522c4cdc003SericR$+ < $+ @ >		$#local $: @ $1			nope, local address')')
52311f06b84Seric
52411f06b84Seric# handle local hacks
52511f06b84SericR$*			$: $>_SET_98_ $1
52671e1a4d1Sericundivert(4)dnl
52771e1a4d1Seric
52807da7f83Sericifdef(`_NO_UUCP_', `dnl',
52907da7f83Seric`# resolve remotely connected UUCP links (if any)
530138c6544Sericifdef(`_CLASS_V_',
53111f06b84Seric`R$* < @ $=V . UUCP > $*		$: < $V > <@ $V> : $1 @ $2.UUCP $3
53211f06b84SericR< $- : $+ > $*			$# $1 $@ $2 $: $3	$=V UUCP routing
53311f06b84SericR< $+ > $*			$#smtp $@ $1 $: $2
53411f06b84SericR<> $*				$: $1			else strip off gunk',
5356dafc3b0Seric	`dnl')
536138c6544Sericifdef(`_CLASS_W_',
53711f06b84Seric`R$* < @ $=W . UUCP > $*		$: < $W > <@ $W> : $1 @ $2.UUCP $3
53811f06b84SericR< $- : $+ > $*			$# $1 $@ $2 $: $3	$=W UUCP routing
53911f06b84SericR< $+ > $*			$#smtp $@ $1 $: $2
54011f06b84SericR<> $*				$: $1			else strip off gunk',
5416dafc3b0Seric	`dnl')
542138c6544Sericifdef(`_CLASS_X_',
54311f06b84Seric`R$* < @ $=X . UUCP > $*		$: < $X > <@ $X> : $1 @ $2.UUCP $3
54411f06b84SericR< $- : $+ > $*			$# $1 $@ $2 $: $3	$=X UUCP routing
54511f06b84SericR< $+ > $*			$#smtp $@ $1 $: $2
54611f06b84SericR<> $*				$: $1			else strip off gunk',
54707da7f83Seric	`dnl')')
54871e1a4d1Seric
5496f4c5567Seric# resolve fake top level domains by forwarding to other hosts
5506f4c5567Sericifdef(`BITNET_RELAY',
55111f06b84Seric`R$*<@$+.BITNET>$*	$: < $B > $1 <@$2.BITNET> $3	user@host.BITNET
55211f06b84SericR< $- : $+ > $*		$# $1 $@ $2 $: $3
55311f06b84SericR< $+ > $*		$#smtp $@ $1 $: $2
55411f06b84SericR<> $*			$: $1				else strip off gunk',
5556f4c5567Seric	`dnl')
5566f4c5567Sericifdef(`CSNET_RELAY',
55711f06b84Seric`R$*<@$+.CSNET>$*	$: < $C > $1 <@$2.CSNET> $3	user@host.CSNET
55811f06b84SericR< $- : $+ > $*		$# $1 $@ $2 $: $3
55911f06b84SericR< $+ > $*		$#smtp $@ $1 $: $2
56011f06b84SericR<> $*			$: $1				else strip off gunk',
5616f4c5567Seric	`dnl')
5625caa7271Sericifdef(`_MAILER_fax_',
5635caa7271Seric`R$+ < @ $+ .FAX >	$#fax $@ $2 $: $1		user@host.FAX',
5645caa7271Seric`ifdef(`FAX_RELAY',
56511f06b84Seric`R$*<@$+.FAX>$*		$: < $F > $1 <@$2.FAX> $3	user@host.FAX
56611f06b84SericR< $- : $+ > $*		$# $1 $@ $2 $: $3
5678e0508d4SericR< $+ > $*		$#smtp $@ $1 $: $2
56811f06b84SericR<> $*			$: $1				else strip off gunk',
5695caa7271Seric	`dnl')')
5706f4c5567Seric
57171e1a4d1Sericifdef(`UUCP_RELAY',
57271e1a4d1Seric`# forward non-local UUCP traffic to our UUCP relay
57311f06b84SericR$*<@$*.UUCP>$*		$: < $Y > <@ $Y> : $1 @ $2.UUCP $3	uucp mail
57411f06b84SericR< $- : $+ > $*		$# $1 $@ $2 $: $3
5758e0508d4SericR< $+ > $*		$#smtp $@ $1 $: $2
57611f06b84SericR<> $*			$: $1				else strip off gunk',
5774cad3747Seric`ifdef(`_MAILER_uucp_',
57871e1a4d1Seric`# forward other UUCP traffic straight to UUCP
579837ed21dSericR< @ $+ .UUCP > : $+	$#uucp $@ $1 $: $2		@host.UUCP:...
58071e1a4d1SericR$+ < @ $+ .UUCP >	$#uucp $@ $2 $: $1		user@host.UUCP',
58171e1a4d1Seric	`dnl')')
582f6f96ca7Sericifdef(`_MAILER_USENET_', `
583f6f96ca7Seric# addresses sent to net.group.USENET will get forwarded to a newsgroup
584f6f96ca7SericR$+ . USENET		$# usenet $: $1',
585f6f96ca7Seric	`dnl')
586f6f96ca7Seric
58785afb57eSericifdef(`_LOCAL_RULES_',
58885afb57eSeric`# figure out what should stay in our local mail system
589f6f96ca7Sericundivert(1)', `dnl')
590f6f96ca7Seric
591*b501d107Sericifdef(`SMART_HOST',
592*b501d107Seric`# pass names that still have a host to a smarthost
59385afb57eSericR$* < @ $* > $*		$: < $S > $1 < @ $2 > $3	glue on smarthost name
59411f06b84SericR< $- : $+ > $*		$# $1 $@ $2 $: $3		if non-null, use it
59511f06b84SericR< $+ > $*		$#suucp $@ $1 $: $2		if non-null, use it
59611f06b84SericR<> $*			$: $1				else strip off gunk',
597f6f96ca7Seric
598f6f96ca7Seric`# deal with other remote names
599*b501d107Sericifdef(`_MAILER_smtp_',
600*b501d107Seric`R$* < @$* > $*		$#smtp $@ $2 $: $1 < @ $2 > $3		user@host.domain',
601*b501d107Seric`R$* < @$* > $*		$#error $@NOHOST $: Unrecognized host name $2')')
6026f4c5567Seric
6034588ece0Sericifdef(`_OLD_SENDMAIL_',
604b1286b66Seric`# forward remaining names to local relay, if any
605adca7ddbSericR$=L			$#local $: $1			special local names
606adca7ddbSericR$+			$: $1 < @ $R >			append relay
607525ff8d9SericR$+ < @ >		$: $1 < @ $H >			no relay, try hub
608525ff8d9SericR$+ < @ >		$#local $: $1			no relay or hub: local
609585ddacfSericR$+ < @ $=w  >		$#local $: $1			we are relay/hub: local
61085afb57eSericR$+ < @ $-:$+ >		$# $2 $@ $3 $: $1		deliver to relay/hub
611e319d9beSericR$+ < @ $+ >		$#relay $@ $2 $: $1		deliver to relay/hub',
612d31361c2Seric
613d31361c2Seric`# if this is quoted, strip the quotes and try again
614d31361c2SericR$+			$: $(dequote $1 $)		strip quotes
615585ddacfSericR$* $=O $*		$@ $>_SET_97_ $1 $2 $3			try again
616d31361c2Seric
617d31361c2Seric# handle locally delivered names
6184588ece0SericR$=L			$#local $: @ $1			special local names
619adca7ddbSericR$+			$#local $: $1			regular local names
6206f4c5567Seric
6214cad3747Seric###########################################################################
6224cad3747Seric###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
6234cad3747Seric###		   (new sendmail only)					###
6244cad3747Seric###########################################################################
6256f4c5567Seric
62663eeb308SericS5
62763eeb308Seric
628fdf362d5Seric# see if we have a relay or a hub
629fdf362d5SericR$+			$: $1 < @ $R >
630525ff8d9SericR$+ < @ >		$: $1 < @ $H >			no relay, try hub
631585ddacfSericR$+ < @ $=w >		$@ $1				we are relay/hub: local
63285afb57eSericR$+ < @ $-:$+ >		$# $2 $@ $3 $: $1		send to relay or hub
633fdf362d5Sericifdef(`_MAILER_smtp_',
634fdf362d5Seric`R$+ < @ $+ >		$#relay $@ $2 $: $1		send to relay or hub')')
635bc926da7Sericifdef(`MAILER_TABLE',
636bc926da7Seric`
637bc926da7Seric
63811f06b84Seric###################################################################
639bc926da7Seric###  Ruleset 90 -- try domain part of mailertable entry 	###
640bc926da7Seric###		   (new sendmail only)				###
64111f06b84Seric###################################################################
642bc926da7Seric
643bc926da7SericS90
644bd6adeb9SericR<$- . $+ > $*		$: < $(mailertable .$2 $) > $3	lookup
645bc926da7SericR<$- : $+ > $*		$# $1 $@ $2 $: $3		check -- resolved?
646f3789658SericR< . $+ > $*		$@ $>90 <$1> $2			no -- strip & try again
647bc926da7SericR<$*> $*		$@ $2				no match',
648bc926da7Seric`dnl')
64911f06b84Seric
65011f06b84Seric###################################################################
65111f06b84Seric###  Ruleset _SET_98_ -- local part of ruleset zero (can be null)	###
65211f06b84Seric###################################################################
65311f06b84Seric
65411f06b84SericS`'_SET_98_
65511f06b84Sericundivert(3)dnl
6566f4c5567Seric#
6576f4c5567Seric######################################################################
6586f4c5567Seric######################################################################
6596f4c5567Seric#####
6601297e20cSeric`#####			MAILER DEFINITIONS'
6616f4c5567Seric#####
6626f4c5567Seric######################################################################
6636f4c5567Seric######################################################################
6646f4c5567Sericundivert(7)dnl
665