xref: /original-bsd/usr.sbin/sendmail/cf/m4/proto.m4 (revision 0f81f0ee)
1divert(-1)
2#
3# Copyright (c) 1983, 1995 Eric P. Allman
4# Copyright (c) 1988, 1993
5#	The Regents of the University of California.  All rights reserved.
6#
7# %sccs.include.redist.sh%
8#
9divert(0)
10
11VERSIONID(`@(#)proto.m4	8.71 (Berkeley) 05/04/95')
12
13MAILER(local)dnl
14
15# level 6 config file format
16V6/Berkeley
17divert(-1)
18
19# do some sanity checking
20ifdef(`__OSTYPE__',,
21	`errprint(`*** ERROR: No system type defined (use OSTYPE macro)')')
22
23# pick our default mailers
24ifdef(`confSMTP_MAILER',, `define(`confSMTP_MAILER', `smtp')')
25ifdef(`confLOCAL_MAILER',, `define(`confLOCAL_MAILER', `local')')
26ifdef(`confRELAY_MAILER',,
27	`define(`confRELAY_MAILER',
28		`ifdef(`_MAILER_smtp_', `relay',
29			`ifdef(`_MAILER_uucp', `suucp', `unknown')')')')
30define(`_SMTP_', `confSMTP_MAILER')dnl		for readability only
31define(`_LOCAL_', `confLOCAL_MAILER')dnl	for readability only
32define(`_RELAY_', `confRELAY_MAILER')dnl	for readability only
33
34# back compatibility with old config files
35ifdef(`confDEF_GROUP_ID',
36	`errprint(`*** confDEF_GROUP_ID is obsolete.')
37	 errprint(`    Use confDEF_USER_ID with a colon in the value instead.')')
38ifdef(`confREAD_TIMEOUT',
39	`errprint(`*** confREAD_TIMEOUT is obsolete.')
40	 errprint(`    Use individual confTO_<timeout> parameters instead.')')
41ifdef(`confMESSAGE_TIMEOUT',
42	`define(`_ARG_', index(confMESSAGE_TIMEOUT, /))
43	 ifelse(_ARG_, -1,
44		`define(`confTO_QUEUERETURN', confMESSAGE_TIMEOUT)',
45		`define(`confTO_QUEUERETURN',
46			substr(confMESSAGE_TIMEOUT, 0, _ARG_))
47		 define(`confTO_QUEUEWARN',
48			substr(confMESSAGE_TIMEOUT, eval(_ARG_+1)))')')
49ifdef(`confMIN_FREE_BLOCKS', `ifelse(index(confMIN_FREE_BLOCKS, /), -1,,
50	`errprint(`*** compound confMIN_FREE_BLOCKS is obsolete.')
51	 errprint(`    Use confMAX_MESSAGE_SIZE for the second part of the value.')')')
52
53# clean option definitions below....
54define(`_OPTION', `ifdef(`$2', `O $1=$2', `#O $1`'ifelse($3, `',, `=$3')')')dnl
55
56divert(0)dnl
57
58##################
59#   local info   #
60##################
61
62Cwlocalhost
63ifdef(`USE_CW_FILE',
64`# file containing names of hosts for which we receive email
65Fw`'confCW_FILE',
66	`dnl')
67
68# my official domain name
69# ... define this only if sendmail cannot automatically determine your domain
70ifdef(`confDOMAIN_NAME', `Dj`'confDOMAIN_NAME', `#Dj$w.Foo.COM')
71
72ifdef(`_NULL_CLIENT_ONLY_', `divert(-1)')dnl
73
74CP.
75
76ifdef(`UUCP_RELAY',
77`# UUCP relay host
78DY`'UUCP_RELAY
79CPUUCP
80
81')dnl
82ifdef(`BITNET_RELAY',
83`#  BITNET relay host
84DB`'BITNET_RELAY
85CPBITNET
86
87')dnl
88ifdef(`FAX_RELAY',
89`# FAX relay host
90DF`'FAX_RELAY
91CPFAX
92
93')dnl
94# "Smart" relay host (may be null)
95DS`'ifdef(`SMART_HOST', SMART_HOST)
96
97ifdef(`LUSER_RELAY',
98`# place to which unknown users should be forwarded
99Kuser user -m -a<>
100DL`'LUSER_RELAY
101', `dnl')
102
103# operators that cannot be in local usernames (i.e., network indicators)
104CO @ % ifdef(`_NO_UUCP_', `', `!')
105
106# a class with just dot (for identifying canonical names)
107C..
108
109ifdef(`MAILER_TABLE',
110`# Mailer table (overriding domains)
111Kmailertable MAILER_TABLE
112
113')dnl
114ifdef(`DOMAIN_TABLE',
115`# Domain table (adding domains)
116Kdomaintable DOMAIN_TABLE
117
118')dnl
119# who I send unqualified names to (null means deliver locally)
120DR`'ifdef(`LOCAL_RELAY', LOCAL_RELAY)
121
122# who gets all local email traffic ($R has precedence for unqualified names)
123DH`'ifdef(`MAIL_HUB', MAIL_HUB)
124
125# class L: names that should be delivered locally, even if we have a relay
126# class E: names that should be exposed as from this host, even if we masquerade
127# class D: dotted names, e.g., root.machinename
128#CL root
129CE root
130undivert(5)dnl
131ifdef(`__DOTTED_USER_LIST__',
132	`__DOTTED_USER_LIST__',
133	`#CD postmaster')
134
135# dequoting map
136Kdequote dequote
137
138divert(0)dnl
139# who I masquerade as (null for no masquerading)
140DM`'ifdef(`MASQUERADE_NAME', MASQUERADE_NAME)
141
142undivert(6)dnl
143
144######################
145#   Special macros   #
146######################
147
148# SMTP initial login message
149De`'confSMTP_LOGIN_MSG
150
151# UNIX initial From header format
152Dl`'confFROM_LINE
153
154# my name for error messages
155Dn`'confMAILER_NAME
156
157# delimiter (operator) characters
158Do`'confOPERATORS
159
160# format of a total name
161Dq`'ifdef(`confFROM_HEADER', confFROM_HEADER, `$?x$x <$g>$|$g$.')
162include(`../m4/version.m4')
163
164###############
165#   Options   #
166###############
167
168# strip message body to 7 bits on input?
169_OPTION(SevenBitInput, `confSEVEN_BIT_INPUT')
170
171# 8-bit data handling
172_OPTION(EightBitMode, `confEIGHT_BIT_HANDLING', adaptive)
173
174# wait for alias file rebuild (default units: minutes)
175_OPTION(AliasWait, `confALIAS_WAIT', 5m)
176
177# location of alias file
178O AliasFile=ifdef(`ALIAS_FILE', `ALIAS_FILE', /etc/aliases)
179
180# minimum number of free blocks on filesystem
181_OPTION(MinFreeBlocks, `confMIN_FREE_BLOCKS', 100)
182
183# maximum message size
184_OPTION(MaxMessageSize, `confMAX_MESSAGE_SIZE', 1000000)
185
186# substitution for space (blank) characters
187_OPTION(BlankSub, `confBLANK_SUB', _)
188
189# avoid connecting to "expensive" mailers on initial submission?
190_OPTION(HoldExpensive, `confCON_EXPENSIVE')
191
192# checkpoint queue runs after every N successful deliveries
193_OPTION(CheckpointInterval, `confCHECKPOINT_INTERVAL', 10)
194
195# default delivery mode
196_OPTION(DeliveryMode, `confDELIVERY_MODE', background)
197
198# automatically rebuild the alias database?
199_OPTION(AutoRebuildAliases, `confAUTO_REBUILD')
200
201# error message header/file
202_OPTION(ErrorHeader, `confERROR_MESSAGE', /etc/sendmail.oE)
203
204# error mode
205_OPTION(ErrorMode, `confERROR_MODE', print)
206
207# save Unix-style "From_" lines at top of header?
208_OPTION(SaveFromLine, `confSAVE_FROM_LINES')
209
210# temporary file mode
211_OPTION(TempFileMode, `confTEMP_FILE_MODE', 0600)
212
213# match recipients against GECOS field?
214_OPTION(MatchGECOS, `confMATCH_GECOS')
215
216# maximum hop count
217_OPTION(MaxHopCount, `confMAX_HOP', 17)
218
219# location of help file
220O HelpFile=ifdef(`HELP_FILE', HELP_FILE, /usr/lib/sendmail.hf)
221
222# ignore dots as terminators in incoming messages?
223_OPTION(IgnoreDots, `confIGNORE_DOTS')
224
225# name resolver options
226_OPTION(ResolverOptions, `confBIND_OPTS', +AAONLY)
227
228# deliver MIME-encapsulated error messages?
229_OPTION(SendMimeErrors, `confMIME_FORMAT_ERRORS')
230
231# Forward file search path
232_OPTION(ForwardPath, `confFORWARD_PATH', /var/forward/$u:$z/.forward.$w:$z/.forward)
233
234# open connection cache size
235_OPTION(ConnectionCacheSize, `confMCI_CACHE_SIZE', 2)
236
237# open connection cache timeout
238_OPTION(ConnectionCacheTimeout, `confMCI_CACHE_TIMEOUT', 5m)
239
240# use Errors-To: header?
241_OPTION(UseErrorsTo, `confUSE_ERRORS_TO')
242
243# log level
244_OPTION(LogLevel, `confLOG_LEVEL', 10)
245
246# send to me too, even in an alias expansion?
247_OPTION(MeToo, `confME_TOO')
248
249# verify RHS in newaliases?
250_OPTION(CheckAliases, `confCHECK_ALIASES')
251
252# default messages to old style headers if no special punctuation?
253_OPTION(OldStyleHeaders, `confOLD_STYLE_HEADERS')
254
255# SMTP daemon options
256_OPTION(DaemonPortOptions, `confDAEMON_OPTIONS', Port=esmtp)
257
258# privacy flags
259_OPTION(PrivacyOptions, `confPRIVACY_FLAGS', authwarnings)
260
261# who (if anyone) should get extra copies of error messages
262_OPTION(PostMasterCopy, `confCOPY_ERRORS_TO', Postmaster)
263
264# slope of queue-only function
265_OPTION(QueueFactor, `confQUEUE_FACTOR', 600000)
266
267# queue directory
268O QueueDirectory=ifdef(`QUEUE_DIR', QUEUE_DIR, /var/spool/mqueue)
269
270# timeouts (many of these)
271_OPTION(Timeout.initial, `confTO_INITIAL', 5m)
272_OPTION(Timeout.helo, `confTO_HELO', 5m)
273_OPTION(Timeout.mail, `confTO_MAIL', 10m)
274_OPTION(Timeout.rcpt, `confTO_RCPT', 1h)
275_OPTION(Timeout.datainit, `confTO_DATAINIT', 5m)
276_OPTION(Timeout.datablock, `confTO_DATABLOCK', 1h)
277_OPTION(Timeout.datafinal, `confTO_DATAFINAL', 1h)
278_OPTION(Timeout.rset, `confTO_RSET', 5m)
279_OPTION(Timeout.quit, `confTO_QUIT', 2m)
280_OPTION(Timeout.misc, `confTO_MISC', 2m)
281_OPTION(Timeout.command, `confTO_COMMAND', 1h)
282_OPTION(Timeout.ident, `confTO_IDENT', 30s)
283_OPTION(Timeout.fileopen, `confTO_FILEOPEN', 60s)
284_OPTION(Timeout.queuereturn, `confTO_QUEUERETURN', 5d)
285_OPTION(Timeout.queuereturn.normal, `confTO_QUEUERETURN_NORMAL', 5d)
286_OPTION(Timeout.queuereturn.urgent, `confTO_QUEUERETURN_URGENT', 2d)
287_OPTION(Timeout.queuereturn.non-urgent, `confTO_QUEUERETURN_NONURGENT', 7d)
288_OPTION(Timeout.queuewarn, `confTO_QUEUEWARN', 4h)
289_OPTION(Timeout.queuewarn.normal, `confTO_QUEUEWARN_NORMAL', 4h)
290_OPTION(Timeout.queuewarn.urgent, `confTO_QUEUEWARN_URGENT', 1h)
291_OPTION(Timeout.queuewarn.non-urgent, `confTO_QUEUEWARN_NONURGENT', 12h)
292
293# should we not prune routes in route-addr syntax addresses?
294_OPTION(DontPruneRoutes, `confDONT_PRUNE_ROUTES')
295
296# queue up everything before forking?
297_OPTION(SuperSafe, `confSAFE_QUEUE')
298
299# status file
300_OPTION(StatusFile, `STATUS_FILE', /etc/sendmail.st)
301
302# time zone handling:
303#  if undefined, use system default
304#  if defined but null, use TZ envariable passed in
305#  if defined and non-null, use that info
306ifelse(confTIME_ZONE, `USE_SYSTEM', `#O TimeZoneSpec=',
307	confTIME_ZONE, `USE_TZ', `O TimeZoneSpec=',
308	`O TimeZoneSpec=confTIME_ZONE')
309
310# default UID (can be username or userid:groupid)
311_OPTION(DefaultUser, `confDEF_USER_ID', nobody)
312
313# list of locations of user database file (null means no lookup)
314_OPTION(UserDatabaseSpec, `confUSERDB_SPEC', /etc/userdb)
315
316# fallback MX host
317_OPTION(FallbackMXhost, `confFALLBACK_MX', fall.back.host.net)
318
319# if we are the best MX host for a site, try it directly instead of config err
320_OPTION(TryNullMXList, `confTRY_NULL_MX_LIST')
321
322# load average at which we just queue messages
323_OPTION(QueueLA, `confQUEUE_LA', 8)
324
325# load average at which we refuse connections
326_OPTION(RefuseLA, `confREFUSE_LA', 12)
327
328# work recipient factor
329_OPTION(RecipientFactor, `confWORK_RECIPIENT_FACTOR', 30000)
330
331# deliver each queued job in a separate process?
332_OPTION(ForkEachJob, `confSEPARATE_PROC')
333
334# work class factor
335_OPTION(ClassFactor, `confWORK_CLASS_FACTOR', 1800)
336
337# work time factor
338_OPTION(RetryFactor, `confWORK_TIME_FACTOR', 90000)
339
340# shall we sort the queue by hostname first?
341_OPTION(QueueSortOrder, `confQUEUE_SORT_ORDER', priority)
342
343# minimum time in queue before retry
344_OPTION(MinQueueAge, `confMIN_QUEUE_AGE', 30m)
345
346# default character set
347_OPTION(DefaultCharSet, `confDEF_CHAR_SET', iso-8859-1)
348
349# service switch file (ignored on Solaris, Ultrix, OSF/1, others)
350_OPTION(ServiceSwitchFile, `confSERVICE_SWITCH_FILE', /etc/service.switch)
351
352# dialup line delay on connection failure
353_OPTION(DialDelay, `confDIAL_DELAY', 10s)
354
355# action to take if there are no recipients in the message
356_OPTION(NoRecipientAction, `confNO_RCPT_ACTION', add-to-undisclosed)
357
358# chrooted environment for writing to files
359_OPTION(SafeFileEnvironment, `confSAFE_FILE_ENV', /arch)
360
361# are colons OK in addresses?
362_OPTION(ColonOkInAddr, `confCOLON_OK_IN_ADDR')
363
364###########################
365#   Message precedences   #
366###########################
367
368Pfirst-class=0
369Pspecial-delivery=100
370Plist=-30
371Pbulk=-60
372Pjunk=-100
373
374#####################
375#   Trusted users   #
376#####################
377
378# this is equivalent to setting class "t"
379#Ft/etc/sendmail.trusted
380Troot
381Tdaemon
382Tuucp
383
384#########################
385#   Format of headers   #
386#########################
387
388H?P?Return-Path: $g
389HReceived: confRECEIVED_HEADER
390H?D?Resent-Date: $a
391H?D?Date: $a
392H?F?Resent-From: $q
393H?F?From: $q
394H?x?Full-Name: $x
395HSubject:
396# HPosted-Date: $a
397# H?l?Received-Date: $b
398H?M?Resent-Message-Id: <$t.$i@$j>
399H?M?Message-Id: <$t.$i@$j>
400ifdef(`_NULL_CLIENT_ONLY_',
401	`include(../m4/nullrelay.m4)m4exit',
402	`dnl')
403#
404######################################################################
405######################################################################
406#####
407#####			REWRITING RULES
408#####
409######################################################################
410######################################################################
411
412undivert(9)dnl
413
414###########################################
415###  Rulset 3 -- Name Canonicalization  ###
416###########################################
417S3
418
419# handle null input (translate to <@> special case)
420R$@			$@ <@>
421
422# strip group: syntax (not inside angle brackets!) and trailing semicolon
423R$*			$: $1 <@>			mark addresses
424R$* < $* > $* <@>	$: $1 < $2 > $3			unmark <addr>
425R$* :: $* <@>		$: $1 :: $2			unmark host::addr
426R:include: $* <@>	$: :include: $1			unmark :include:...
427R$* : $* <@>		$: $2				strip colon if marked
428R$* <@>			$: $1				unmark
429R$* ;			$: $1				strip trailing semi
430
431# null input now results from list:; syntax
432R$@			$@ :; <@>
433
434# basic textual canonicalization -- note RFC733 heuristic here
435R$*<$*>$*<$*>$*		$2$3<$4>$5			strip multiple <> <>
436R$*<$*<$+>$*>$*		<$3>$5				2-level <> nesting
437R$*<>$*			$@ <@>				MAIL FROM:<> case
438R$*<$+>$*		$2				basic RFC821/822 parsing
439
440# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
441R@ $+ , $+		@ $1 : $2			change all "," to ":"
442
443# localize and dispose of route-based addresses
444R@ $+ : $+		$@ $>96 < @$1 > : $2		handle <route-addr>
445
446# find focus for list syntax
447R $+ : $* ; @ $+	$@ $>96 $1 : $2 ; < @ $3 >	list syntax
448R $+ : $* ;		$@ $1 : $2;			list syntax
449
450# find focus for @ syntax addresses
451R$+ @ $+		$: $1 < @ $2 >			focus on domain
452R$+ < $+ @ $+ >		$1 $2 < @ $3 >			move gaze right
453R$+ < @ $+ >		$@ $>96 $1 < @ $2 >		already canonical
454
455# do some sanity checking
456R$* < @ $* : $* > $*	$1 < @ $2 $3 > $4		nix colons in addrs
457
458ifdef(`_NO_UUCP_', `dnl',
459`# convert old-style addresses to a domain-based address
460R$- ! $+		$@ $>96 $2 < @ $1 .UUCP >	resolve uucp names
461R$+ . $- ! $+		$@ $>96 $3 < @ $1 . $2 >		domain uucps
462R$+ ! $+		$@ $>96 $2 < @ $1 .UUCP >	uucp subdomains')
463
464# if we have % signs, take the rightmost one
465R$* % $*		$1 @ $2				First make them all @s.
466R$* @ $* @ $*		$1 % $2 @ $3			Undo all but the last.
467R$* @ $*		$@ $>96 $1 < @ $2 >		Insert < > and finish
468
469# else we must be a local name
470
471
472################################################
473###  Ruleset 96 -- bottom half of ruleset 3  ###
474################################################
475
476#  At this point, everything should be in a "local_part<@domain>extra" format.
477S96
478
479# handle special cases for local names
480R$* < @ localhost > $*		$: $1 < @ $j . > $2		no domain at all
481R$* < @ localhost . $m > $*	$: $1 < @ $j . > $2		local domain
482ifdef(`_NO_UUCP_', `dnl',
483`R$* < @ localhost . UUCP > $*	$: $1 < @ $j . > $2		.UUCP domain')
484R$* < @ [ $+ ] > $*		$: $1 < @@ [ $2 ] > $3		mark [a.b.c.d]
485R$* < @@ $=w > $*		$: $1 < @ $j . > $3		self-literal
486R$* < @@ $+ > $*		$@ $1 < @ $2 > $3		canon IP addr
487ifdef(`DOMAIN_TABLE', `
488# look up domains in the domain table
489R$* < @ $+ > $*			$: $1 < @ $(domaintable $2 $) > $3',
490`dnl')
491undivert(2)dnl
492
493ifdef(`_NO_UUCP_', `dnl',
494`ifdef(`UUCP_RELAY',
495`# pass UUCP addresses straight through
496R$* < @ $+ . UUCP > $*		$@ $1 < @ $2 . UUCP . > $3',
497`# if really UUCP, handle it immediately
498ifdef(`_CLASS_U_',
499`R$* < @ $=U . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
500ifdef(`_CLASS_V_',
501`R$* < @ $=V . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
502ifdef(`_CLASS_W_',
503`R$* < @ $=W . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
504ifdef(`_CLASS_X_',
505`R$* < @ $=X . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
506ifdef(`_CLASS_Y_',
507`R$* < @ $=Y . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
508
509# try UUCP traffic as a local address
510R$* < @ $+ . UUCP > $*		$: $1 < @ $[ $2 $] . UUCP . > $3
511R$* < @ $+ . . UUCP . > $*		$@ $1 < @ $2 . > $3')
512')
513ifdef(`_NO_CANONIFY_', `dnl',
514`# pass to name server to make hostname canonical
515R$* < @ $* $~P > $*		$: $1 < @ $[ $2 $3 $] > $4')
516
517# local host aliases and pseudo-domains are always canonical
518R$* < @ $=w > $*		$: $1 < @ $2 . > $3
519R$* < @ $* $=P > $*		$: $1 < @ $2 $3 . > $4
520R$* < @ $* . . > $*		$1 < @ $2 . > $3
521
522# if this is the local hostname, make sure we treat is as canonical
523R$* < @ $j > $*			$: $1 < @ $j . > $2
524
525
526##################################################
527###  Ruleset 4 -- Final Output Post-rewriting  ###
528##################################################
529S4
530
531R$* <@>			$@				handle <> and list:;
532
533# strip trailing dot off possibly canonical name
534R$* < @ $+ . > $*	$1 < @ $2 > $3
535
536# externalize local domain info
537R$* < $+ > $*		$1 $2 $3			defocus
538R@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
539R@ $*			$@ @ $1				... and exit
540
541ifdef(`_NO_UUCP_', `dnl',
542`# UUCP must always be presented in old form
543R$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u')
544
545# delete duplicate local names
546R$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
547
548
549
550##############################################################
551###   Ruleset 97 -- recanonicalize and call ruleset zero   ###
552###		   (used for recursive calls)		   ###
553##############################################################
554
555S`'97
556R$*			$: $>3 $1
557R$*			$@ $>0 $1
558
559
560######################################
561###   Ruleset 0 -- Parse Address   ###
562######################################
563
564S0
565
566R<@>			$#_LOCAL_ $: <@>		special case error msgs
567R$* : $* ; <@>		$#error $@ 5.1.3 $: "list:; syntax illegal for recipient addresses"
568R<@ $+>			$#error $@ 5.1.1 $: "user address required"
569R$* <$* : $* > $*	$#error $@ 5.1.1 $: "colon illegal in host name part"
570R$* < @ . > $*		$#error $@ 5.1.2 $: "invalid host name"
571
572ifdef(`_MAILER_smtp_',
573`# handle numeric address spec
574R$* < @ [ $+ ] > $*	$: $>98 $1 < @ [ $2 ] > $3	numeric internet spec
575R$* < @ [ $+ ] > $*	$#_SMTP_ $@ [$2] $: $1 < @ [$2] > $3	still numeric: send',
576	`dnl')
577
578# now delete the local info -- note $=O to find characters that cause forwarding
579R$* < @ > $*		$@ $>97 $1		user@ => user
580R< @ $=w . > : $*	$@ $>97 $2		@here:... -> ...
581R$* $=O $* < @ $=w . >	$@ $>97 $1 $2 $3		...@here -> ...
582
583# handle local hacks
584R$*			$: $>98 $1
585
586# short circuit local delivery so forwarded email works
587ifdef(`_STICKY_LOCAL_DOMAIN_',
588`R$+ < @ $=w . >		$: < $H > $1 < @ $2 . >		first try hub
589R< $+ > $+ < $+ >	$>95 < $1 > $2 < $3 >		yep ....
590R< > $=D . $+ < $+ >	$#_LOCAL_ $: $1 . $2		dotted name?
591R< > $+ + $* < $+ >	$#_LOCAL_ $: $1 + $2		plussed name?
592R< > $+ < $+ >		$#_LOCAL_ $: @ $1			nope, local address',
593`R$=L < @ $=w . >	$#_LOCAL_ $: @ $1		special local names
594R$+ < @ $=w . >		$#_LOCAL_ $: $1			regular local name')
595ifdef(`MAILER_TABLE',
596`
597# not local -- try mailer table lookup
598R$* <@ $+ > $*		$: < $2 > $1 < @ $2 > $3	extract host name
599R< $+ . > $*		$: < $1 > $2			strip trailing dot
600R< $+ > $*		$: < $(mailertable $1 $) > $2	lookup
601R< $- : $+ > $*		$# $1 $@ $2 $: $3		check -- resolved?
602R< $+ > $*		$: $>90 <$1> $2			try domain',
603`dnl')
604undivert(4)dnl
605
606ifdef(`_NO_UUCP_', `dnl',
607`# resolve remotely connected UUCP links (if any)
608ifdef(`_CLASS_V_',
609`R$* < @ $=V . UUCP . > $*		$: $>95 < $V > $1 <@$2.UUCP.> $3',
610	`dnl')
611ifdef(`_CLASS_W_',
612`R$* < @ $=W . UUCP . > $*		$: $>95 < $W > $1 <@$2.UUCP.> $3',
613	`dnl')
614ifdef(`_CLASS_X_',
615`R$* < @ $=X . UUCP . > $*		$: $>95 < $X > $1 <@$2.UUCP.> $3',
616	`dnl')')
617
618# resolve fake top level domains by forwarding to other hosts
619ifdef(`BITNET_RELAY',
620`R$*<@$+.BITNET.>$*	$: $>95 < $B > $1 <@$2.BITNET.> $3	user@host.BITNET',
621	`dnl')
622ifdef(`_MAILER_pop_',
623`R$+ < @ POP. >		$#pop $: $1			user@POP',
624	`dnl')
625ifdef(`_MAILER_fax_',
626`R$+ < @ $+ .FAX. >	$#fax $@ $2 $: $1		user@host.FAX',
627`ifdef(`FAX_RELAY',
628`R$*<@$+.FAX.>$*		$: $>95 < $F > $1 <@$2.FAX.> $3	user@host.FAX',
629	`dnl')')
630
631ifdef(`UUCP_RELAY',
632`# forward non-local UUCP traffic to our UUCP relay
633R$*<@$*.UUCP.>$*		$: $>95 < $Y > $1 <@$2.UUCP.> $3	uucp mail',
634`ifdef(`_MAILER_uucp_',
635`# forward other UUCP traffic straight to UUCP
636R$* < @ $+ .UUCP. > $*		$#uucp $@ $2 $: $1 < @ $2 .UUCP. > $3	user@host.UUCP',
637	`dnl')')
638ifdef(`_MAILER_usenet_', `
639# addresses sent to net.group.USENET will get forwarded to a newsgroup
640R$+ . USENET		$#usenet $: $1',
641	`dnl')
642
643ifdef(`_LOCAL_RULES_',
644`# figure out what should stay in our local mail system
645undivert(1)', `dnl')
646
647# pass names that still have a host to a smarthost (if defined)
648R$* < @ $* > $*		$: $>95 < $S > $1 < @ $2 > $3	glue on smarthost name
649
650# deal with other remote names
651ifdef(`_MAILER_smtp_',
652`R$* < @$* > $*		$#_SMTP_ $@ $2 $: $1 < @ $2 > $3		user@host.domain',
653`R$* < @$* > $*		$#error $@ 5.1.2 $: Unrecognized host name $2')
654
655# if this is quoted, strip the quotes and try again
656R$+			$: $(dequote $1 $)		strip quotes
657R$+ $=O $+		$@ $>97 $1 $2 $3			try again
658
659# handle locally delivered names
660R$=L			$#_LOCAL_ $: @ $1			special local names
661R$+			$#_LOCAL_ $: $1			regular local names
662
663###########################################################################
664###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
665###########################################################################
666
667S5
668
669# if we have a "special dotted user", convert it back to the base name
670R$=D . *		$#_LOCAL_ $: $1
671R$=D . $+		$#_LOCAL_ $: $1 . *
672
673# prepend an empty "forward host" on the front
674R$+			$: <> $1
675
676ifdef(`LUSER_RELAY',
677`# send unrecognized local users to a relay host
678R< > $+ + $*		$: < $L . > $( user $1 $) + $2
679R< > $+			$: < $L . > $( user $1 $)	look up user
680R< $* > $+ <> $*	$: < > $2 $3			found; strip $L
681R< $* . > $+		$: < $1 > $2			strip extra dot')
682
683# handle plussed local names
684R< > $+ + $*		$#_LOCAL_ $@ $2 $: $1
685
686# see if we have a relay or a hub
687R< > $+			$: < $H > $1			try hub
688R< > $+			$: < $R > $1			try relay
689R< > $+			$@ $1				nope, give up
690R< $- : $+ > $+		$: $>95 < $1 : $2 > $3 < @ $2 >
691R< $+ > $+		$@ $>95 < $1 > $2 < @ $1 >
692ifdef(`MAILER_TABLE',
693`
694
695###################################################################
696###  Ruleset 90 -- try domain part of mailertable entry 	###
697###################################################################
698
699S90
700R$* <$- . $+ > $*	$: $1$2 < $(mailertable .$3 $@ $1$2 $@ $2 $) > $4
701R$* <$- : $+ > $*	$# $2 $@ $3 $: $4		check -- resolved?
702R$* < . $+ > $*		$@ $>90 $1 . <$2> $3		no -- strip & try again
703R$* < $* > $*		$: < $(mailertable . $@ $1$2 $) > $3	try "."
704R<$- : $+ > $*		$# $1 $@ $2 $: $3		"." found?
705R< $* > $*		$@ $2				no mailertable match',
706`dnl')
707
708###################################################################
709###  Ruleset 95 -- canonify mailer:host syntax to triple	###
710###################################################################
711
712S95
713R< > $*			$@ $1				strip off null relay
714R< $- : $+ > $*		$# $1 $@ $2 $: $3		try qualified mailer
715R< $=w > $*		$@ $2				delete local host
716R< $+ > $*		$#_RELAY_ $@ $1 $: $2		use unqualified mailer
717
718###################################################################
719###  Ruleset 98 -- local part of ruleset zero (can be null)	###
720###################################################################
721
722S98
723undivert(3)dnl
724#
725######################################################################
726######################################################################
727#####
728`#####			MAILER DEFINITIONS'
729#####
730######################################################################
731######################################################################
732undivert(7)dnl
733