xref: /csrg-svn/usr.sbin/sendmail/cf/m4/proto.m4 (revision 69853)
151222Sericdivert(-1)
251222Seric#
368840Seric# Copyright (c) 1983, 1995 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*69853SericVERSIONID(`@(#)proto.m4	8.80 (Berkeley) 06/10/95')
1251222Seric
1351322SericMAILER(local)dnl
1451222Seric
1567696Seric# level 6 config file format
1668651SericV6/Berkeley
1768651Sericdivert(-1)
1868651Seric
1968830Seric# do some sanity checking
2068830Sericifdef(`__OSTYPE__',,
2168830Seric	`errprint(`*** ERROR: No system type defined (use OSTYPE macro)')')
2268830Seric
2368651Seric# pick our default mailers
2468651Sericifdef(`confSMTP_MAILER',, `define(`confSMTP_MAILER', `smtp')')
2568651Sericifdef(`confLOCAL_MAILER',, `define(`confLOCAL_MAILER', `local')')
2664010Sericifdef(`confRELAY_MAILER',,
2764010Seric	`define(`confRELAY_MAILER',
2864010Seric		`ifdef(`_MAILER_smtp_', `relay',
2968651Seric			`ifdef(`_MAILER_uucp', `suucp', `unknown')')')')
3063998Sericdefine(`_SMTP_', `confSMTP_MAILER')dnl		for readability only
3163998Sericdefine(`_LOCAL_', `confLOCAL_MAILER')dnl	for readability only
3264010Sericdefine(`_RELAY_', `confRELAY_MAILER')dnl	for readability only
3352646Seric
3468651Seric# back compatibility with old config files
3568651Sericifdef(`confDEF_GROUP_ID',
3668651Seric	`errprint(`*** confDEF_GROUP_ID is obsolete.')
3768651Seric	 errprint(`    Use confDEF_USER_ID with a colon in the value instead.')')
3868651Sericifdef(`confREAD_TIMEOUT',
3968651Seric	`errprint(`*** confREAD_TIMEOUT is obsolete.')
4068651Seric	 errprint(`    Use individual confTO_<timeout> parameters instead.')')
4168651Sericifdef(`confMESSAGE_TIMEOUT',
4268651Seric	`define(`_ARG_', index(confMESSAGE_TIMEOUT, /))
4368651Seric	 ifelse(_ARG_, -1,
4468651Seric		`define(`confTO_QUEUERETURN', confMESSAGE_TIMEOUT)',
4568651Seric		`define(`confTO_QUEUERETURN',
4668651Seric			substr(confMESSAGE_TIMEOUT, 0, _ARG_))
4768651Seric		 define(`confTO_QUEUEWARN',
4868651Seric			substr(confMESSAGE_TIMEOUT, eval(_ARG_+1)))')')
4968651Sericifdef(`confMIN_FREE_BLOCKS', `ifelse(index(confMIN_FREE_BLOCKS, /), -1,,
5068651Seric	`errprint(`*** compound confMIN_FREE_BLOCKS is obsolete.')
5168651Seric	 errprint(`    Use confMAX_MESSAGE_SIZE for the second part of the value.')')')
5268651Seric
5368651Seric# clean option definitions below....
5468651Sericdefine(`_OPTION', `ifdef(`$2', `O $1=$2', `#O $1`'ifelse($3, `',, `=$3')')')dnl
5568651Seric
5668651Sericdivert(0)dnl
5768651Seric
5851222Seric##################
5951222Seric#   local info   #
6051222Seric##################
6151222Seric
6251889SericCwlocalhost
6351887Sericifdef(`USE_CW_FILE',
6451889Seric`# file containing names of hosts for which we receive email
6564033SericFw`'confCW_FILE',
6664033Seric	`dnl')
6768651Seric
6864321Seric# my official domain name
6968651Seric# ... define this only if sendmail cannot automatically determine your domain
7068651Sericifdef(`confDOMAIN_NAME', `Dj`'confDOMAIN_NAME', `#Dj$w.Foo.COM')
7151222Seric
7268651Sericifdef(`_NULL_CLIENT_ONLY_', `divert(-1)')dnl
7364321Seric
7464321SericCP.
7564321Seric
7651222Sericifdef(`UUCP_RELAY',
7751222Seric`# UUCP relay host
7864033SericDY`'UUCP_RELAY
7960212SericCPUUCP
8057944Seric
8151222Seric')dnl
8251222Sericifdef(`BITNET_RELAY',
8351222Seric`#  BITNET relay host
8464033SericDB`'BITNET_RELAY
8560212SericCPBITNET
8657944Seric
8751222Seric')dnl
8869625Sericifdef(`DECNET_RELAY',
8969629Seric`define(`_USE_DECNET_SYNTAX_')dnl
9069625Seric# DECnet relay host
9169625SericDC`'DECNET_RELAY
9269625SericCPDECNET
9369625Seric
9469625Seric')dnl
9558364Sericifdef(`FAX_RELAY',
9658364Seric`# FAX relay host
9764033SericDF`'FAX_RELAY
9860212SericCPFAX
9958364Seric
10058364Seric')dnl
10164321Seric# "Smart" relay host (may be null)
10264321SericDS`'ifdef(`SMART_HOST', SMART_HOST)
10351222Seric
10467914Sericifdef(`LUSER_RELAY',
10567914Seric`# place to which unknown users should be forwarded
10667914SericKuser user -m -a<>
10767914SericDL`'LUSER_RELAY
10867914Seric', `dnl')
10967914Seric
11068651Seric# operators that cannot be in local usernames (i.e., network indicators)
11168651SericCO @ % ifdef(`_NO_UUCP_', `', `!')
11268651Seric
11368651Seric# a class with just dot (for identifying canonical names)
11468651SericC..
11568651Seric
11658781Sericifdef(`MAILER_TABLE',
11758781Seric`# Mailer table (overriding domains)
11858781SericKmailertable MAILER_TABLE
11958781Seric
12058781Seric')dnl
12163754Sericifdef(`DOMAIN_TABLE',
12263754Seric`# Domain table (adding domains)
12363754SericKdomaintable DOMAIN_TABLE
12463754Seric
12563754Seric')dnl
12651222Seric# who I send unqualified names to (null means deliver locally)
12764033SericDR`'ifdef(`LOCAL_RELAY', LOCAL_RELAY)
12851222Seric
12957527Seric# who gets all local email traffic ($R has precedence for unqualified names)
13064033SericDH`'ifdef(`MAIL_HUB', MAIL_HUB)
13157527Seric
13257245Seric# class L: names that should be delivered locally, even if we have a relay
13357245Seric# class E: names that should be exposed as from this host, even if we masquerade
13467538Seric#CL root
13567538SericCE root
13651279Sericundivert(5)dnl
13751279Seric
13867469Seric# dequoting map
13967469SericKdequote dequote
14057944Seric
14168651Sericdivert(0)dnl
14268651Seric# who I masquerade as (null for no masquerading)
14368651SericDM`'ifdef(`MASQUERADE_NAME', MASQUERADE_NAME)
14468651Seric
14559033Sericundivert(6)dnl
14659033Seric
14757944Seric######################
14857944Seric#   Special macros   #
14957944Seric######################
15057944Seric
15157944Seric# SMTP initial login message
15264033SericDe`'confSMTP_LOGIN_MSG
15357944Seric
15457944Seric# UNIX initial From header format
15564033SericDl`'confFROM_LINE
15657944Seric
15757944Seric# my name for error messages
15864033SericDn`'confMAILER_NAME
15957944Seric
16057944Seric# delimiter (operator) characters
16164033SericDo`'confOPERATORS
16257944Seric
16357944Seric# format of a total name
16467538SericDq`'ifdef(`confFROM_HEADER', confFROM_HEADER, `$?x$x <$g>$|$g$.')
16557944Sericinclude(`../m4/version.m4')
16657944Seric
16757944Seric###############
16857944Seric#   Options   #
16957944Seric###############
17057944Seric
17159887Seric# strip message body to 7 bits on input?
17268651Seric_OPTION(SevenBitInput, `confSEVEN_BIT_INPUT')
17357944Seric
17467550Seric# 8-bit data handling
17568651Seric_OPTION(EightBitMode, `confEIGHT_BIT_HANDLING', adaptive)
17667550Seric
17768651Seric# wait for alias file rebuild (default units: minutes)
17868651Seric_OPTION(AliasWait, `confALIAS_WAIT', 5m)
17957944Seric
18057944Seric# location of alias file
18168651SericO AliasFile=ifdef(`ALIAS_FILE', `ALIAS_FILE', /etc/aliases)
18257944Seric
18358084Seric# minimum number of free blocks on filesystem
18468651Seric_OPTION(MinFreeBlocks, `confMIN_FREE_BLOCKS', 100)
18558084Seric
18668651Seric# maximum message size
18768651Seric_OPTION(MaxMessageSize, `confMAX_MESSAGE_SIZE', 1000000)
18868651Seric
18957944Seric# substitution for space (blank) characters
19068651Seric_OPTION(BlankSub, `confBLANK_SUB', _)
19157944Seric
19265618Seric# avoid connecting to "expensive" mailers on initial submission?
19368651Seric_OPTION(HoldExpensive, `confCON_EXPENSIVE')
19457944Seric
19557944Seric# checkpoint queue runs after every N successful deliveries
19668651Seric_OPTION(CheckpointInterval, `confCHECKPOINT_INTERVAL', 10)
19757944Seric
19857944Seric# default delivery mode
19968651Seric_OPTION(DeliveryMode, `confDELIVERY_MODE', background)
20057944Seric
20157944Seric# automatically rebuild the alias database?
20268651Seric_OPTION(AutoRebuildAliases, `confAUTO_REBUILD')
20357944Seric
20464033Seric# error message header/file
20568651Seric_OPTION(ErrorHeader, `confERROR_MESSAGE', /etc/sendmail.oE)
20657944Seric
20757944Seric# error mode
20868651Seric_OPTION(ErrorMode, `confERROR_MODE', print)
20957944Seric
21057944Seric# save Unix-style "From_" lines at top of header?
21168651Seric_OPTION(SaveFromLine, `confSAVE_FROM_LINES')
21257944Seric
21357944Seric# temporary file mode
21468651Seric_OPTION(TempFileMode, `confTEMP_FILE_MODE', 0600)
21557944Seric
21657944Seric# match recipients against GECOS field?
21768651Seric_OPTION(MatchGECOS, `confMATCH_GECOS')
21857944Seric
21957944Seric# maximum hop count
22068651Seric_OPTION(MaxHopCount, `confMAX_HOP', 17)
22157944Seric
22257944Seric# location of help file
22368651SericO HelpFile=ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf)
22457944Seric
22557944Seric# ignore dots as terminators in incoming messages?
22668651Seric_OPTION(IgnoreDots, `confIGNORE_DOTS')
22757944Seric
22868651Seric# name resolver options
22968651Seric_OPTION(ResolverOptions, `confBIND_OPTS', +AAONLY)
23057944Seric
23159887Seric# deliver MIME-encapsulated error messages?
23268651Seric_OPTION(SendMimeErrors, `confMIME_FORMAT_ERRORS')
23359887Seric
23457944Seric# Forward file search path
23568651Seric_OPTION(ForwardPath, `confFORWARD_PATH', /var/forward/$u:$z/.forward.$w:$z/.forward)
23657944Seric
23757944Seric# open connection cache size
23868651Seric_OPTION(ConnectionCacheSize, `confMCI_CACHE_SIZE', 2)
23957944Seric
24057944Seric# open connection cache timeout
24168651Seric_OPTION(ConnectionCacheTimeout, `confMCI_CACHE_TIMEOUT', 5m)
24257944Seric
24361106Seric# use Errors-To: header?
24468651Seric_OPTION(UseErrorsTo, `confUSE_ERRORS_TO')
24561106Seric
24657944Seric# log level
24768651Seric_OPTION(LogLevel, `confLOG_LEVEL', 10)
24857944Seric
24957944Seric# send to me too, even in an alias expansion?
25068651Seric_OPTION(MeToo, `confME_TOO')
25157944Seric
25257944Seric# verify RHS in newaliases?
25368651Seric_OPTION(CheckAliases, `confCHECK_ALIASES')
25457944Seric
25557944Seric# default messages to old style headers if no special punctuation?
25668651Seric_OPTION(OldStyleHeaders, `confOLD_STYLE_HEADERS')
25757944Seric
25858860Seric# SMTP daemon options
25968651Seric_OPTION(DaemonPortOptions, `confDAEMON_OPTIONS', Port=esmtp)
26058860Seric
26158084Seric# privacy flags
26268651Seric_OPTION(PrivacyOptions, `confPRIVACY_FLAGS', authwarnings)
26358084Seric
26457944Seric# who (if anyone) should get extra copies of error messages
26568651Seric_OPTION(PostMasterCopy, `confCOPY_ERRORS_TO', Postmaster)
26657944Seric
26757944Seric# slope of queue-only function
26868651Seric_OPTION(QueueFactor, `confQUEUE_FACTOR', 600000)
26957944Seric
27057944Seric# queue directory
27168651SericO QueueDirectory=ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue)
27257944Seric
27368651Seric# timeouts (many of these)
27468651Seric_OPTION(Timeout.initial, `confTO_INITIAL', 5m)
27568651Seric_OPTION(Timeout.helo, `confTO_HELO', 5m)
27668651Seric_OPTION(Timeout.mail, `confTO_MAIL', 10m)
27768651Seric_OPTION(Timeout.rcpt, `confTO_RCPT', 1h)
27868651Seric_OPTION(Timeout.datainit, `confTO_DATAINIT', 5m)
27968651Seric_OPTION(Timeout.datablock, `confTO_DATABLOCK', 1h)
28068651Seric_OPTION(Timeout.datafinal, `confTO_DATAFINAL', 1h)
28168651Seric_OPTION(Timeout.rset, `confTO_RSET', 5m)
28268651Seric_OPTION(Timeout.quit, `confTO_QUIT', 2m)
28368651Seric_OPTION(Timeout.misc, `confTO_MISC', 2m)
28468651Seric_OPTION(Timeout.command, `confTO_COMMAND', 1h)
28568651Seric_OPTION(Timeout.ident, `confTO_IDENT', 30s)
28668651Seric_OPTION(Timeout.fileopen, `confTO_FILEOPEN', 60s)
28768651Seric_OPTION(Timeout.queuereturn, `confTO_QUEUERETURN', 5d)
28868651Seric_OPTION(Timeout.queuereturn.normal, `confTO_QUEUERETURN_NORMAL', 5d)
28968651Seric_OPTION(Timeout.queuereturn.urgent, `confTO_QUEUERETURN_URGENT', 2d)
29068651Seric_OPTION(Timeout.queuereturn.non-urgent, `confTO_QUEUERETURN_NONURGENT', 7d)
29168651Seric_OPTION(Timeout.queuewarn, `confTO_QUEUEWARN', 4h)
29268651Seric_OPTION(Timeout.queuewarn.normal, `confTO_QUEUEWARN_NORMAL', 4h)
29368651Seric_OPTION(Timeout.queuewarn.urgent, `confTO_QUEUEWARN_URGENT', 1h)
29468651Seric_OPTION(Timeout.queuewarn.non-urgent, `confTO_QUEUEWARN_NONURGENT', 12h)
29557944Seric
29667810Seric# should we not prune routes in route-addr syntax addresses?
29768651Seric_OPTION(DontPruneRoutes, `confDONT_PRUNE_ROUTES')
29867810Seric
29957944Seric# queue up everything before forking?
30068651Seric_OPTION(SuperSafe, `confSAFE_QUEUE')
30157944Seric
30257944Seric# status file
30369761SericO StatusFile=ifdef(`STATUS_FILE', `STATUS_FILE', /etc/sendmail.st)
30457944Seric
30557944Seric# time zone handling:
30657944Seric#  if undefined, use system default
30757944Seric#  if defined but null, use TZ envariable passed in
30857944Seric#  if defined and non-null, use that info
30968651Sericifelse(confTIME_ZONE, `USE_SYSTEM', `#O TimeZoneSpec=',
31068651Seric	confTIME_ZONE, `USE_TZ', `O TimeZoneSpec=',
31168651Seric	`O TimeZoneSpec=confTIME_ZONE')
31257944Seric
31368651Seric# default UID (can be username or userid:groupid)
31468651Seric_OPTION(DefaultUser, `confDEF_USER_ID', nobody)
31557944Seric
31651887Seric# list of locations of user database file (null means no lookup)
31768651Seric_OPTION(UserDatabaseSpec, `confUSERDB_SPEC', /etc/userdb)
31851222Seric
31958860Seric# fallback MX host
32068651Seric_OPTION(FallbackMXhost, `confFALLBACK_MX', fall.back.host.net)
32158860Seric
32263858Seric# if we are the best MX host for a site, try it directly instead of config err
32368651Seric_OPTION(TryNullMXList, `confTRY_NULL_MX_LIST')
32463858Seric
32557944Seric# load average at which we just queue messages
32668651Seric_OPTION(QueueLA, `confQUEUE_LA', 8)
32757944Seric
32857944Seric# load average at which we refuse connections
32968651Seric_OPTION(RefuseLA, `confREFUSE_LA', 12)
33057944Seric
33157944Seric# work recipient factor
33268651Seric_OPTION(RecipientFactor, `confWORK_RECIPIENT_FACTOR', 30000)
33357944Seric
33457944Seric# deliver each queued job in a separate process?
33568651Seric_OPTION(ForkEachJob, `confSEPARATE_PROC')
33657944Seric
33757944Seric# work class factor
33868651Seric_OPTION(ClassFactor, `confWORK_CLASS_FACTOR', 1800)
33957944Seric
34057944Seric# work time factor
34168651Seric_OPTION(RetryFactor, `confWORK_TIME_FACTOR', 90000)
34257944Seric
34367697Seric# shall we sort the queue by hostname first?
34468651Seric_OPTION(QueueSortOrder, `confQUEUE_SORT_ORDER', priority)
34567697Seric
34668651Seric# minimum time in queue before retry
34768651Seric_OPTION(MinQueueAge, `confMIN_QUEUE_AGE', 30m)
34868651Seric
34968651Seric# default character set
35068651Seric_OPTION(DefaultCharSet, `confDEF_CHAR_SET', iso-8859-1)
35168651Seric
35268651Seric# service switch file (ignored on Solaris, Ultrix, OSF/1, others)
35368651Seric_OPTION(ServiceSwitchFile, `confSERVICE_SWITCH_FILE', /etc/service.switch)
35468651Seric
35568651Seric# dialup line delay on connection failure
35668651Seric_OPTION(DialDelay, `confDIAL_DELAY', 10s)
35768651Seric
35868651Seric# action to take if there are no recipients in the message
35968651Seric_OPTION(NoRecipientAction, `confNO_RCPT_ACTION', add-to-undisclosed)
36068651Seric
36168651Seric# chrooted environment for writing to files
36268651Seric_OPTION(SafeFileEnvironment, `confSAFE_FILE_ENV', /arch)
36368651Seric
36468806Seric# are colons OK in addresses?
36568806Seric_OPTION(ColonOkInAddr, `confCOLON_OK_IN_ADDR')
36668806Seric
36769734Seric# how many jobs can you process in the queue?
36869734Seric_OPTION(MaxQueueRunSize, `confMAX_QUEUE_RUN_SIZE', 10000)
36969734Seric
370*69853Seric# shall I avoid expanding CNAMEs (violates protocols)?
371*69853Seric_OPTION(DontExpandCnames, `confDONT_EXPAND_CNAMES')
372*69853Seric
37357944Seric###########################
37457944Seric#   Message precedences   #
37557944Seric###########################
37657944Seric
37757944SericPfirst-class=0
37857944SericPspecial-delivery=100
37958070SericPlist=-30
38057944SericPbulk=-60
38157944SericPjunk=-100
38257944Seric
38357944Seric#####################
38457944Seric#   Trusted users   #
38557944Seric#####################
38657944Seric
38768651Seric# this is equivalent to setting class "t"
38868651Seric#Ft/etc/sendmail.trusted
38957944SericTroot
39057944SericTdaemon
39157944SericTuucp
39257944Seric
39357944Seric#########################
39457944Seric#   Format of headers   #
39557944Seric#########################
39657944Seric
39758679SericH?P?Return-Path: $g
39867819SericHReceived: confRECEIVED_HEADER
39957944SericH?D?Resent-Date: $a
40057944SericH?D?Date: $a
40157944SericH?F?Resent-From: $q
40257944SericH?F?From: $q
40357944SericH?x?Full-Name: $x
40457944SericHSubject:
40557944Seric# HPosted-Date: $a
40657944Seric# H?l?Received-Date: $b
40757944SericH?M?Resent-Message-Id: <$t.$i@$j>
40857944SericH?M?Message-Id: <$t.$i@$j>
40968651Sericifdef(`_NULL_CLIENT_ONLY_',
41068651Seric	`include(../m4/nullrelay.m4)m4exit',
41168651Seric	`dnl')
41251222Seric#
41351222Seric######################################################################
41451222Seric######################################################################
41551222Seric#####
41651222Seric#####			REWRITING RULES
41751222Seric#####
41851222Seric######################################################################
41951222Seric######################################################################
42051222Seric
42158678Sericundivert(9)dnl
42251222Seric
42351222Seric###########################################
42451222Seric###  Rulset 3 -- Name Canonicalization  ###
42551222Seric###########################################
42651260SericS3
42751222Seric
42864802Seric# handle null input (translate to <@> special case)
42958499SericR$@			$@ <@>
43058174Seric
43168763Seric# strip group: syntax (not inside angle brackets!) and trailing semicolon
43268763SericR$*			$: $1 <@>			mark addresses
43368763SericR$* < $* > $* <@>	$: $1 < $2 > $3			unmark <addr>
43469625SericR$* :: $* <@>		$: $1 :: $2			unmark node::addr
43569779SericR:`include': $* <@>	$: :`include': $1			unmark :`include':...
43668763SericR$* : $* <@>		$: $2				strip colon if marked
43768763SericR$* <@>			$: $1				unmark
43868763SericR$* ;			$: $1				strip trailing semi
43968763Seric
44068763Seric# null input now results from list:; syntax
44168763SericR$@			$@ :; <@>
44268763Seric
44351222Seric# basic textual canonicalization -- note RFC733 heuristic here
44464144SericR$*<$*>$*<$*>$*		$2$3<$4>$5			strip multiple <> <>
44558158SericR$*<$*<$+>$*>$*		<$3>$5				2-level <> nesting
44658499SericR$*<>$*			$@ <@>				MAIL FROM:<> case
44751222SericR$*<$+>$*		$2				basic RFC821/822 parsing
44851222Seric
44951222Seric# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
45055416SericR@ $+ , $+		@ $1 : $2			change all "," to ":"
45151222Seric
45251222Seric# localize and dispose of route-based addresses
45367469SericR@ $+ : $+		$@ $>96 < @$1 > : $2		handle <route-addr>
45451222Seric
45551222Seric# find focus for list syntax
45667469SericR $+ : $* ; @ $+	$@ $>96 $1 : $2 ; < @ $3 >	list syntax
45755416SericR $+ : $* ;		$@ $1 : $2;			list syntax
45851222Seric
45951222Seric# find focus for @ syntax addresses
46055416SericR$+ @ $+		$: $1 < @ $2 >			focus on domain
46155416SericR$+ < $+ @ $+ >		$1 $2 < @ $3 >			move gaze right
46267469SericR$+ < @ $+ >		$@ $>96 $1 < @ $2 >		already canonical
46351222Seric
46464968Seric# do some sanity checking
46564968SericR$* < @ $* : $* > $*	$1 < @ $2 $3 > $4		nix colons in addrs
46664968Seric
46758288Sericifdef(`_NO_UUCP_', `dnl',
46858288Seric`# convert old-style addresses to a domain-based address
46967469SericR$- ! $+		$@ $>96 $2 < @ $1 .UUCP >	resolve uucp names
47067469SericR$+ . $- ! $+		$@ $>96 $3 < @ $1 . $2 >		domain uucps
47169625SericR$+ ! $+		$@ $>96 $2 < @ $1 .UUCP >	uucp subdomains
47269625Seric')
47369629Sericifdef(`_USE_DECNET_SYNTAX_',
47469625Seric`# convert node::user addresses into a domain-based address
47569625SericR$- :: $+		$@ $>96 $2 < @ $1 .DECNET >	resolve DECnet names
47669629SericR$- . $- :: $+		$@ $>96 $3 < @ $1.$2 .DECNET >	numeric DECnet addr
47769625Seric',
47869625Seric	`dnl')
47951222Seric# if we have % signs, take the rightmost one
48055416SericR$* % $*		$1 @ $2				First make them all @s.
48155416SericR$* @ $* @ $*		$1 % $2 @ $3			Undo all but the last.
48267469SericR$* @ $*		$@ $>96 $1 < @ $2 >		Insert < > and finish
48351222Seric
48451222Seric# else we must be a local name
48569542SericR$*			$@ $>96 $1
48651222Seric
48751222Seric
48860894Seric################################################
48967469Seric###  Ruleset 96 -- bottom half of ruleset 3  ###
49060894Seric################################################
49151222Seric
49267469SericS96
49351222Seric
49451222Seric# handle special cases for local names
49560262SericR$* < @ localhost > $*		$: $1 < @ $j . > $2		no domain at all
49660262SericR$* < @ localhost . $m > $*	$: $1 < @ $j . > $2		local domain
49760262Sericifdef(`_NO_UUCP_', `dnl',
49860262Seric`R$* < @ localhost . UUCP > $*	$: $1 < @ $j . > $2		.UUCP domain')
49965825SericR$* < @ [ $+ ] > $*		$: $1 < @@ [ $2 ] > $3		mark [a.b.c.d]
50065825SericR$* < @@ $=w > $*		$: $1 < @ $j . > $3		self-literal
50166306SericR$* < @@ $+ > $*		$@ $1 < @ $2 > $3		canon IP addr
50263754Sericifdef(`DOMAIN_TABLE', `
50367450Seric# look up domains in the domain table
50467450SericR$* < @ $+ > $*			$: $1 < @ $(domaintable $2 $) > $3',
50563754Seric`dnl')
50651889Sericundivert(2)dnl
50751222Seric
50859081Sericifdef(`_NO_UUCP_', `dnl',
50959081Seric`ifdef(`UUCP_RELAY',
51051274Seric`# pass UUCP addresses straight through
51164971SericR$* < @ $+ . UUCP > $*		$@ $1 < @ $2 . UUCP . > $3',
51251274Seric`# if really UUCP, handle it immediately
51351322Sericifdef(`_CLASS_U_',
51464971Seric`R$* < @ $=U . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
51551322Sericifdef(`_CLASS_V_',
51664971Seric`R$* < @ $=V . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
51751322Sericifdef(`_CLASS_W_',
51864971Seric`R$* < @ $=W . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
51951322Sericifdef(`_CLASS_X_',
52064971Seric`R$* < @ $=X . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
52151322Sericifdef(`_CLASS_Y_',
52264971Seric`R$* < @ $=Y . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
52351267Seric
52451267Seric# try UUCP traffic as a local address
52564971SericR$* < @ $+ . UUCP > $*		$: $1 < @ $[ $2 $] . UUCP . > $3
52667469SericR$* < @ $+ . . UUCP . > $*		$@ $1 < @ $2 . > $3')
52759081Seric')
52865061Sericifdef(`_NO_CANONIFY_', `dnl',
52959081Seric`# pass to name server to make hostname canonical
53061470SericR$* < @ $* $~P > $*		$: $1 < @ $[ $2 $3 $] > $4')
53161470Seric
53265061Seric# local host aliases and pseudo-domains are always canonical
53365061SericR$* < @ $=w > $*		$: $1 < @ $2 . > $3
53464971SericR$* < @ $* $=P > $*		$: $1 < @ $2 $3 . > $4
53565061SericR$* < @ $* . . > $*		$1 < @ $2 . > $3
53664971Seric
53751322Seric# if this is the local hostname, make sure we treat is as canonical
53851322SericR$* < @ $j > $*			$: $1 < @ $j . > $2
53951222Seric
54051322Seric
54151222Seric##################################################
54251222Seric###  Ruleset 4 -- Final Output Post-rewriting  ###
54351222Seric##################################################
54451222SericS4
54551222Seric
54669215SericR$* <@>			$@				handle <> and list:;
54751222Seric
54851322Seric# strip trailing dot off possibly canonical name
54951322SericR$* < @ $+ . > $*	$1 < @ $2 > $3
55051322Seric
55151222Seric# externalize local domain info
55251322SericR$* < $+ > $*		$1 $2 $3			defocus
55351322SericR@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
55451997SericR@ $*			$@ @ $1				... and exit
55551222Seric
55658288Sericifdef(`_NO_UUCP_', `dnl',
55758288Seric`# UUCP must always be presented in old form
55858288SericR$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u')
55951222Seric
56069629Sericifdef(`_USE_DECNET_SYNTAX_',
56169629Seric`# put DECnet back in :: form
56269629SericR$+ @ $+ . DECNET	$2 :: $1			u@h.DECNET => h::u',
56369629Seric	`dnl')
56451222Seric# delete duplicate local names
56551322SericR$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
56651222Seric
56751222Seric
56851222Seric
56960894Seric##############################################################
57067469Seric###   Ruleset 97 -- recanonicalize and call ruleset zero   ###
57160894Seric###		   (used for recursive calls)		   ###
57260894Seric##############################################################
57351222Seric
57467469SericS`'97
57551222SericR$*			$: $>3 $1
57651222SericR$*			$@ $>0 $1
57751222Seric
57851222Seric
57951222Seric######################################
58051222Seric###   Ruleset 0 -- Parse Address   ###
58151222Seric######################################
58251222Seric
58351222SericS0
58451222Seric
58567118SericR<@>			$#_LOCAL_ $: <@>		special case error msgs
58668852SericR$* : $* ; <@>		$#error $@ 5.1.3 $: "list:; syntax illegal for recipient addresses"
58768852SericR<@ $+>			$#error $@ 5.1.1 $: "user address required"
58868852SericR$* <$* : $* > $*	$#error $@ 5.1.1 $: "colon illegal in host name part"
58968852SericR$* < @ . > $*		$#error $@ 5.1.2 $: "invalid host name"
59058340Seric
59155416Sericifdef(`_MAILER_smtp_',
59255416Seric`# handle numeric address spec
59367469SericR$* < @ [ $+ ] > $*	$: $>98 $1 < @ [ $2 ] > $3	numeric internet spec
59465191SericR$* < @ [ $+ ] > $*	$#_SMTP_ $@ [$2] $: $1 < @ [$2] > $3	still numeric: send',
59563858Seric	`dnl')
59651222Seric
59751887Seric# now delete the local info -- note $=O to find characters that cause forwarding
59867469SericR$* < @ > $*		$@ $>97 $1		user@ => user
59967469SericR< @ $=w . > : $*	$@ $>97 $2		@here:... -> ...
60067469SericR$* $=O $* < @ $=w . >	$@ $>97 $1 $2 $3		...@here -> ...
60163967Seric
60263967Seric# handle local hacks
60367469SericR$*			$: $>98 $1
60466048Seric
60566048Seric# short circuit local delivery so forwarded email works
60669844Sericifdef(`_MAILER_usenet_',
60769844Seric`R$+ . USENET < @ $=w . >	$#usenet $: $1		handle usenet specially',
60869844Seric	`dnl')
60967914Sericifdef(`_STICKY_LOCAL_DOMAIN_',
61067914Seric`R$+ < @ $=w . >		$: < $H > $1 < @ $2 . >		first try hub
61168698SericR< $+ > $+ < $+ >	$>95 < $1 > $2 < $3 >		yep ....
61268155SericR< > $+ + $* < $+ >	$#_LOCAL_ $: $1 + $2		plussed name?
61367914SericR< > $+ < $+ >		$#_LOCAL_ $: @ $1			nope, local address',
61468698Seric`R$=L < @ $=w . >	$#_LOCAL_ $: @ $1		special local names
61568155SericR$+ < @ $=w . >		$#_LOCAL_ $: $1			regular local name')
61666090Sericifdef(`MAILER_TABLE',
61766090Seric`
61866090Seric# not local -- try mailer table lookup
61966090SericR$* <@ $+ > $*		$: < $2 > $1 < @ $2 > $3	extract host name
62066090SericR< $+ . > $*		$: < $1 > $2			strip trailing dot
62166090SericR< $+ > $*		$: < $(mailertable $1 $) > $2	lookup
62266090SericR< $- : $+ > $*		$# $1 $@ $2 $: $3		check -- resolved?
62366090SericR< $+ > $*		$: $>90 <$1> $2			try domain',
62466090Seric`dnl')
62551260Sericundivert(4)dnl
62651260Seric
62761468Sericifdef(`_NO_UUCP_', `dnl',
62861468Seric`# resolve remotely connected UUCP links (if any)
62951285Sericifdef(`_CLASS_V_',
63067469Seric`R$* < @ $=V . UUCP . > $*		$: $>95 < $V > $1 <@$2.UUCP.> $3',
63152044Seric	`dnl')
63251285Sericifdef(`_CLASS_W_',
63367469Seric`R$* < @ $=W . UUCP . > $*		$: $>95 < $W > $1 <@$2.UUCP.> $3',
63452044Seric	`dnl')
63551285Sericifdef(`_CLASS_X_',
63667469Seric`R$* < @ $=X . UUCP . > $*		$: $>95 < $X > $1 <@$2.UUCP.> $3',
63761468Seric	`dnl')')
63851260Seric
63951222Seric# resolve fake top level domains by forwarding to other hosts
64051222Sericifdef(`BITNET_RELAY',
64167469Seric`R$*<@$+.BITNET.>$*	$: $>95 < $B > $1 <@$2.BITNET.> $3	user@host.BITNET',
64251222Seric	`dnl')
64369625Sericifdef(`DECNET_RELAY',
64469625Seric`R$*<@$+.DECNET.>$*	$: $>95 < $C > $1 <@$2.DECNET.> $3	user@host.DECNET',
64569625Seric	`dnl')
64665149Sericifdef(`_MAILER_pop_',
64765149Seric`R$+ < @ POP. >		$#pop $: $1			user@POP',
64865149Seric	`dnl')
64958364Sericifdef(`_MAILER_fax_',
65064971Seric`R$+ < @ $+ .FAX. >	$#fax $@ $2 $: $1		user@host.FAX',
65158364Seric`ifdef(`FAX_RELAY',
65267469Seric`R$*<@$+.FAX.>$*		$: $>95 < $F > $1 <@$2.FAX.> $3	user@host.FAX',
65358364Seric	`dnl')')
65451222Seric
65551260Sericifdef(`UUCP_RELAY',
65651260Seric`# forward non-local UUCP traffic to our UUCP relay
65767469SericR$*<@$*.UUCP.>$*		$: $>95 < $Y > $1 <@$2.UUCP.> $3	uucp mail',
65855416Seric`ifdef(`_MAILER_uucp_',
65951260Seric`# forward other UUCP traffic straight to UUCP
66065557SericR$* < @ $+ .UUCP. > $*		$#uucp $@ $2 $: $1 < @ $2 .UUCP. > $3	user@host.UUCP',
66151260Seric	`dnl')')
66263967Sericifdef(`_MAILER_usenet_', `
66363754Seric# addresses sent to net.group.USENET will get forwarded to a newsgroup
66465851SericR$+ . USENET		$#usenet $: $1',
66563860Seric	`dnl')
66663754Seric
66758070Sericifdef(`_LOCAL_RULES_',
66858070Seric`# figure out what should stay in our local mail system
66963754Sericundivert(1)', `dnl')
67063754Seric
67164321Seric# pass names that still have a host to a smarthost (if defined)
67267469SericR$* < @ $* > $*		$: $>95 < $S > $1 < @ $2 > $3	glue on smarthost name
67363754Seric
67464321Seric# deal with other remote names
67563946Sericifdef(`_MAILER_smtp_',
67663973Seric`R$* < @$* > $*		$#_SMTP_ $@ $2 $: $1 < @ $2 > $3		user@host.domain',
67768852Seric`R$* < @$* > $*		$#error $@ 5.1.2 $: Unrecognized host name $2')
67851222Seric
67967469Seric# if this is quoted, strip the quotes and try again
68058811SericR$+			$: $(dequote $1 $)		strip quotes
68167469SericR$+ $=O $+		$@ $>97 $1 $2 $3			try again
68258811Seric
68358811Seric# handle locally delivered names
68463998SericR$=L			$#_LOCAL_ $: @ $1			special local names
68563998SericR$+			$#_LOCAL_ $: $1			regular local names
68651222Seric
68755416Seric###########################################################################
68855416Seric###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
68955416Seric###########################################################################
69051222Seric
69151322SericS5
69251322Seric
69369542Seric# deal with plussed users so aliases work nicely
69469542SericR$+ + *			$#_LOCAL_ $@ $&h $: $1
69569542SericR$+ + $*		$#_LOCAL_ $@ $2 $: $1 + *
69667538Seric
69767914Seric# prepend an empty "forward host" on the front
69867914SericR$+			$: <> $1
69967914Seric
70067914Sericifdef(`LUSER_RELAY',
70167914Seric`# send unrecognized local users to a relay host
70268149SericR< > $+ + $*		$: < $L . > $( user $1 $) + $2
70368149SericR< > $+			$: < $L . > $( user $1 $)	look up user
70468149SericR< $* > $+ <> $*	$: < > $2 $3			found; strip $L
70568149SericR< $* . > $+		$: < $1 > $2			strip extra dot')
70667914Seric
70768149Seric# handle plussed local names
70868149SericR< > $+ + $*		$#_LOCAL_ $@ $2 $: $1
70968149Seric
71058808Seric# see if we have a relay or a hub
71168698SericR< > $+			$: < $H > $1			try hub
71267914SericR< > $+			$: < $R > $1			try relay
71366048SericR< > $+			$@ $1				nope, give up
71467469SericR< $- : $+ > $+		$: $>95 < $1 : $2 > $3 < @ $2 >
71567469SericR< $+ > $+		$@ $>95 < $1 > $2 < @ $1 >
71660540Sericifdef(`MAILER_TABLE',
71760540Seric`
71860540Seric
71963858Seric###################################################################
72063858Seric###  Ruleset 90 -- try domain part of mailertable entry 	###
72163858Seric###################################################################
72260540Seric
72360540SericS90
72466091SericR$* <$- . $+ > $*	$: $1$2 < $(mailertable .$3 $@ $1$2 $@ $2 $) > $4
72566081SericR$* <$- : $+ > $*	$# $2 $@ $3 $: $4		check -- resolved?
72666081SericR$* < . $+ > $*		$@ $>90 $1 . <$2> $3		no -- strip & try again
72766094SericR$* < $* > $*		$: < $(mailertable . $@ $1$2 $) > $3	try "."
72866090SericR<$- : $+ > $*		$# $1 $@ $2 $: $3		"." found?
72966090SericR< $* > $*		$@ $2				no mailertable match',
73060540Seric`dnl')
73163858Seric
73263858Seric###################################################################
73367469Seric###  Ruleset 95 -- canonify mailer:host syntax to triple	###
73464010Seric###################################################################
73564010Seric
73667469SericS95
73764010SericR< > $*			$@ $1				strip off null relay
73864010SericR< $- : $+ > $*		$# $1 $@ $2 $: $3		try qualified mailer
73964010SericR< $=w > $*		$@ $2				delete local host
74064010SericR< $+ > $*		$#_RELAY_ $@ $1 $: $2		use unqualified mailer
74164010Seric
74264010Seric###################################################################
74367469Seric###  Ruleset 98 -- local part of ruleset zero (can be null)	###
74463858Seric###################################################################
74563858Seric
74667469SericS98
74763858Sericundivert(3)dnl
74851222Seric#
74951222Seric######################################################################
75051222Seric######################################################################
75151222Seric#####
75256790Seric`#####			MAILER DEFINITIONS'
75351222Seric#####
75451222Seric######################################################################
75551222Seric######################################################################
75651222Sericundivert(7)dnl
757