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