xref: /original-bsd/usr.sbin/sendmail/cf/m4/proto.m4 (revision 681f9c33)
1divert(-1)
2#
3# Copyright (c) 1983 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.63 (Berkeley) 03/30/95')
12
13MAILER(local)dnl
14
15# level 6 config file format
16V6/Berkeley
17divert(-1)
18
19# pick our default mailers
20ifdef(`confSMTP_MAILER',, `define(`confSMTP_MAILER', `smtp')')
21ifdef(`confLOCAL_MAILER',, `define(`confLOCAL_MAILER', `local')')
22ifdef(`confRELAY_MAILER',,
23	`define(`confRELAY_MAILER',
24		`ifdef(`_MAILER_smtp_', `relay',
25			`ifdef(`_MAILER_uucp', `suucp', `unknown')')')')
26define(`_SMTP_', `confSMTP_MAILER')dnl		for readability only
27define(`_LOCAL_', `confLOCAL_MAILER')dnl	for readability only
28define(`_RELAY_', `confRELAY_MAILER')dnl	for readability only
29
30# back compatibility with old config files
31ifdef(`confDEF_GROUP_ID',
32	`errprint(`*** confDEF_GROUP_ID is obsolete.')
33	 errprint(`    Use confDEF_USER_ID with a colon in the value instead.')')
34ifdef(`confREAD_TIMEOUT',
35	`errprint(`*** confREAD_TIMEOUT is obsolete.')
36	 errprint(`    Use individual confTO_<timeout> parameters instead.')')
37ifdef(`confMESSAGE_TIMEOUT',
38	`define(`_ARG_', index(confMESSAGE_TIMEOUT, /))
39	 ifelse(_ARG_, -1,
40		`define(`confTO_QUEUERETURN', confMESSAGE_TIMEOUT)',
41		`define(`confTO_QUEUERETURN',
42			substr(confMESSAGE_TIMEOUT, 0, _ARG_))
43		 define(`confTO_QUEUEWARN',
44			substr(confMESSAGE_TIMEOUT, eval(_ARG_+1)))')')
45ifdef(`confMIN_FREE_BLOCKS', `ifelse(index(confMIN_FREE_BLOCKS, /), -1,,
46	`errprint(`*** compound confMIN_FREE_BLOCKS is obsolete.')
47	 errprint(`    Use confMAX_MESSAGE_SIZE for the second part of the value.')')')
48
49# clean option definitions below....
50define(`_OPTION', `ifdef(`$2', `O $1=$2', `#O $1`'ifelse($3, `',, `=$3')')')dnl
51
52divert(0)dnl
53
54##################
55#   local info   #
56##################
57
58Cwlocalhost
59ifdef(`USE_CW_FILE',
60`# file containing names of hosts for which we receive email
61Fw`'confCW_FILE',
62	`dnl')
63
64# my official domain name
65# ... define this only if sendmail cannot automatically determine your domain
66ifdef(`confDOMAIN_NAME', `Dj`'confDOMAIN_NAME', `#Dj$w.Foo.COM')
67
68ifdef(`_NULL_CLIENT_ONLY_', `divert(-1)')dnl
69
70CP.
71
72ifdef(`UUCP_RELAY',
73`# UUCP relay host
74DY`'UUCP_RELAY
75CPUUCP
76
77')dnl
78ifdef(`BITNET_RELAY',
79`#  BITNET relay host
80DB`'BITNET_RELAY
81CPBITNET
82
83')dnl
84ifdef(`FAX_RELAY',
85`# FAX relay host
86DF`'FAX_RELAY
87CPFAX
88
89')dnl
90# "Smart" relay host (may be null)
91DS`'ifdef(`SMART_HOST', SMART_HOST)
92
93ifdef(`LUSER_RELAY',
94`# place to which unknown users should be forwarded
95Kuser user -m -a<>
96DL`'LUSER_RELAY
97', `dnl')
98
99# operators that cannot be in local usernames (i.e., network indicators)
100CO @ % ifdef(`_NO_UUCP_', `', `!')
101
102# a class with just dot (for identifying canonical names)
103C..
104
105ifdef(`MAILER_TABLE',
106`# Mailer table (overriding domains)
107Kmailertable MAILER_TABLE
108
109')dnl
110ifdef(`DOMAIN_TABLE',
111`# Domain table (adding domains)
112Kdomaintable DOMAIN_TABLE
113
114')dnl
115# who I send unqualified names to (null means deliver locally)
116DR`'ifdef(`LOCAL_RELAY', LOCAL_RELAY)
117
118# who gets all local email traffic ($R has precedence for unqualified names)
119DH`'ifdef(`MAIL_HUB', MAIL_HUB)
120
121# class L: names that should be delivered locally, even if we have a relay
122# class E: names that should be exposed as from this host, even if we masquerade
123# class D: dotted names, e.g., root.machinename
124#CL root
125CE root
126undivert(5)dnl
127ifdef(`__DOTTED_USER_LIST__',
128	`__DOTTED_USER_LIST__',
129	`#CD postmaster')
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# do our SMTP peers choke on multi-line greeting messages?
337_OPTION(BrokenSmtpPeers, `confBROKEN_SMTP_PEERS')
338
339# shall we sort the queue by hostname first?
340_OPTION(QueueSortOrder, `confQUEUE_SORT_ORDER', priority)
341
342# minimum time in queue before retry
343_OPTION(MinQueueAge, `confMIN_QUEUE_AGE', 30m)
344
345# default character set
346_OPTION(DefaultCharSet, `confDEF_CHAR_SET', iso-8859-1)
347
348# service switch file (ignored on Solaris, Ultrix, OSF/1, others)
349_OPTION(ServiceSwitchFile, `confSERVICE_SWITCH_FILE', /etc/service.switch)
350
351# dialup line delay on connection failure
352_OPTION(DialDelay, `confDIAL_DELAY', 10s)
353
354# action to take if there are no recipients in the message
355_OPTION(NoRecipientAction, `confNO_RCPT_ACTION', add-to-undisclosed)
356
357# chrooted environment for writing to files
358_OPTION(SafeFileEnvironment, `confSAFE_FILE_ENV', /arch)
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# basic textual canonicalization -- note RFC733 heuristic here
419R$*<$*>$*<$*>$*		$2$3<$4>$5			strip multiple <> <>
420R$*<$*<$+>$*>$*		<$3>$5				2-level <> nesting
421R$*<>$*			$@ <@>				MAIL FROM:<> case
422R$*<$+>$*		$2				basic RFC821/822 parsing
423
424# handle list:; syntax as special case
425R$*:;$*			$@ $1 :; <@>
426
427# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
428R@ $+ , $+		@ $1 : $2			change all "," to ":"
429
430# localize and dispose of route-based addresses
431R@ $+ : $+		$@ $>96 < @$1 > : $2		handle <route-addr>
432
433# find focus for list syntax
434R $+ : $* ; @ $+	$@ $>96 $1 : $2 ; < @ $3 >	list syntax
435R $+ : $* ;		$@ $1 : $2;			list syntax
436
437# find focus for @ syntax addresses
438R$+ @ $+		$: $1 < @ $2 >			focus on domain
439R$+ < $+ @ $+ >		$1 $2 < @ $3 >			move gaze right
440R$+ < @ $+ >		$@ $>96 $1 < @ $2 >		already canonical
441
442# do some sanity checking
443R$* < @ $* : $* > $*	$1 < @ $2 $3 > $4		nix colons in addrs
444
445ifdef(`_NO_UUCP_', `dnl',
446`# convert old-style addresses to a domain-based address
447R$- ! $+		$@ $>96 $2 < @ $1 .UUCP >	resolve uucp names
448R$+ . $- ! $+		$@ $>96 $3 < @ $1 . $2 >		domain uucps
449R$+ ! $+		$@ $>96 $2 < @ $1 .UUCP >	uucp subdomains')
450
451# if we have % signs, take the rightmost one
452R$* % $*		$1 @ $2				First make them all @s.
453R$* @ $* @ $*		$1 % $2 @ $3			Undo all but the last.
454R$* @ $*		$@ $>96 $1 < @ $2 >		Insert < > and finish
455
456# else we must be a local name
457
458
459################################################
460###  Ruleset 96 -- bottom half of ruleset 3  ###
461################################################
462
463#  At this point, everything should be in a "local_part<@domain>extra" format.
464S96
465
466# handle special cases for local names
467R$* < @ localhost > $*		$: $1 < @ $j . > $2		no domain at all
468R$* < @ localhost . $m > $*	$: $1 < @ $j . > $2		local domain
469ifdef(`_NO_UUCP_', `dnl',
470`R$* < @ localhost . UUCP > $*	$: $1 < @ $j . > $2		.UUCP domain')
471R$* < @ [ $+ ] > $*		$: $1 < @@ [ $2 ] > $3		mark [a.b.c.d]
472R$* < @@ $=w > $*		$: $1 < @ $j . > $3		self-literal
473R$* < @@ $+ > $*		$@ $1 < @ $2 > $3		canon IP addr
474ifdef(`DOMAIN_TABLE', `
475# look up domains in the domain table
476R$* < @ $+ > $*			$: $1 < @ $(domaintable $2 $) > $3',
477`dnl')
478undivert(2)dnl
479
480ifdef(`_NO_UUCP_', `dnl',
481`ifdef(`UUCP_RELAY',
482`# pass UUCP addresses straight through
483R$* < @ $+ . UUCP > $*		$@ $1 < @ $2 . UUCP . > $3',
484`# if really UUCP, handle it immediately
485ifdef(`_CLASS_U_',
486`R$* < @ $=U . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
487ifdef(`_CLASS_V_',
488`R$* < @ $=V . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
489ifdef(`_CLASS_W_',
490`R$* < @ $=W . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
491ifdef(`_CLASS_X_',
492`R$* < @ $=X . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
493ifdef(`_CLASS_Y_',
494`R$* < @ $=Y . UUCP > $*	$@ $1 < @ $2 . UUCP . > $3', `dnl')
495
496# try UUCP traffic as a local address
497R$* < @ $+ . UUCP > $*		$: $1 < @ $[ $2 $] . UUCP . > $3
498R$* < @ $+ . . UUCP . > $*		$@ $1 < @ $2 . > $3')
499')
500ifdef(`_NO_CANONIFY_', `dnl',
501`# pass to name server to make hostname canonical
502R$* < @ $* $~P > $*		$: $1 < @ $[ $2 $3 $] > $4')
503
504# local host aliases and pseudo-domains are always canonical
505R$* < @ $=w > $*		$: $1 < @ $2 . > $3
506R$* < @ $* $=P > $*		$: $1 < @ $2 $3 . > $4
507R$* < @ $* . . > $*		$1 < @ $2 . > $3
508
509# if this is the local hostname, make sure we treat is as canonical
510R$* < @ $j > $*			$: $1 < @ $j . > $2
511
512
513##################################################
514###  Ruleset 4 -- Final Output Post-rewriting  ###
515##################################################
516S4
517
518R$*<@>			$@ $1				handle <> and list:;
519
520# strip trailing dot off possibly canonical name
521R$* < @ $+ . > $*	$1 < @ $2 > $3
522
523# externalize local domain info
524R$* < $+ > $*		$1 $2 $3			defocus
525R@ $+ : @ $+ : $+	@ $1 , @ $2 : $3		<route-addr> canonical
526R@ $*			$@ @ $1				... and exit
527
528ifdef(`_NO_UUCP_', `dnl',
529`# UUCP must always be presented in old form
530R$+ @ $- . UUCP		$2!$1				u@h.UUCP => h!u')
531
532# delete duplicate local names
533R$+ % $=w @ $=w		$1 @ $j				u%host@host => u@host
534
535
536
537##############################################################
538###   Ruleset 97 -- recanonicalize and call ruleset zero   ###
539###		   (used for recursive calls)		   ###
540##############################################################
541
542S`'97
543R$*			$: $>3 $1
544R$*			$@ $>0 $1
545
546
547######################################
548###   Ruleset 0 -- Parse Address   ###
549######################################
550
551S0
552
553R<@>			$#_LOCAL_ $: <@>		special case error msgs
554R$* : $* ;		$#error $@ USAGE $: "list:; syntax illegal for recipient addresses"
555R<@ $+>			$#error $@ USAGE $: "user address required"
556R$* <$* : $* > $*	$#error $@ USAGE $: "colon illegal in host name part"
557R$* < @ . > $*		$#error $@ USAGE $: "invalid host name"
558
559ifdef(`_MAILER_smtp_',
560`# handle numeric address spec
561R$* < @ [ $+ ] > $*	$: $>98 $1 < @ [ $2 ] > $3	numeric internet spec
562R$* < @ [ $+ ] > $*	$#_SMTP_ $@ [$2] $: $1 < @ [$2] > $3	still numeric: send',
563	`dnl')
564
565# now delete the local info -- note $=O to find characters that cause forwarding
566R$* < @ > $*		$@ $>97 $1		user@ => user
567R< @ $=w . > : $*	$@ $>97 $2		@here:... -> ...
568R$* $=O $* < @ $=w . >	$@ $>97 $1 $2 $3		...@here -> ...
569
570# handle local hacks
571R$*			$: $>98 $1
572
573# short circuit local delivery so forwarded email works
574ifdef(`_STICKY_LOCAL_DOMAIN_',
575`R$+ < @ $=w . >		$: < $H > $1 < @ $2 . >		first try hub
576R< $+ > $+ < $+ >	$#_LOCAL_ $: $2			yep ....
577R< > $=D . $+ < $+ >	$#_LOCAL_ $: $1 . $2		dotted name?
578R< > $+ + $* < $+ >	$#_LOCAL_ $: $1 + $2		plussed name?
579R< > $+ < $+ >		$#_LOCAL_ $: @ $1			nope, local address',
580`R$=L < @ $=w . >		$#_LOCAL_ $: @ $1			special local names
581R$+ < @ $=w . >		$#_LOCAL_ $: $1			regular local name')
582ifdef(`MAILER_TABLE',
583`
584# not local -- try mailer table lookup
585R$* <@ $+ > $*		$: < $2 > $1 < @ $2 > $3	extract host name
586R< $+ . > $*		$: < $1 > $2			strip trailing dot
587R< $+ > $*		$: < $(mailertable $1 $) > $2	lookup
588R< $- : $+ > $*		$# $1 $@ $2 $: $3		check -- resolved?
589R< $+ > $*		$: $>90 <$1> $2			try domain',
590`dnl')
591undivert(4)dnl
592
593ifdef(`_NO_UUCP_', `dnl',
594`# resolve remotely connected UUCP links (if any)
595ifdef(`_CLASS_V_',
596`R$* < @ $=V . UUCP . > $*		$: $>95 < $V > $1 <@$2.UUCP.> $3',
597	`dnl')
598ifdef(`_CLASS_W_',
599`R$* < @ $=W . UUCP . > $*		$: $>95 < $W > $1 <@$2.UUCP.> $3',
600	`dnl')
601ifdef(`_CLASS_X_',
602`R$* < @ $=X . UUCP . > $*		$: $>95 < $X > $1 <@$2.UUCP.> $3',
603	`dnl')')
604
605# resolve fake top level domains by forwarding to other hosts
606ifdef(`BITNET_RELAY',
607`R$*<@$+.BITNET.>$*	$: $>95 < $B > $1 <@$2.BITNET.> $3	user@host.BITNET',
608	`dnl')
609ifdef(`_MAILER_pop_',
610`R$+ < @ POP. >		$#pop $: $1			user@POP',
611	`dnl')
612ifdef(`_MAILER_fax_',
613`R$+ < @ $+ .FAX. >	$#fax $@ $2 $: $1		user@host.FAX',
614`ifdef(`FAX_RELAY',
615`R$*<@$+.FAX.>$*		$: $>95 < $F > $1 <@$2.FAX.> $3	user@host.FAX',
616	`dnl')')
617
618ifdef(`UUCP_RELAY',
619`# forward non-local UUCP traffic to our UUCP relay
620R$*<@$*.UUCP.>$*		$: $>95 < $Y > $1 <@$2.UUCP.> $3	uucp mail',
621`ifdef(`_MAILER_uucp_',
622`# forward other UUCP traffic straight to UUCP
623R$* < @ $+ .UUCP. > $*		$#uucp $@ $2 $: $1 < @ $2 .UUCP. > $3	user@host.UUCP',
624	`dnl')')
625ifdef(`_MAILER_usenet_', `
626# addresses sent to net.group.USENET will get forwarded to a newsgroup
627R$+ . USENET		$#usenet $: $1',
628	`dnl')
629
630ifdef(`_LOCAL_RULES_',
631`# figure out what should stay in our local mail system
632undivert(1)', `dnl')
633
634# pass names that still have a host to a smarthost (if defined)
635R$* < @ $* > $*		$: $>95 < $S > $1 < @ $2 > $3	glue on smarthost name
636
637# deal with other remote names
638ifdef(`_MAILER_smtp_',
639`R$* < @$* > $*		$#_SMTP_ $@ $2 $: $1 < @ $2 > $3		user@host.domain',
640`R$* < @$* > $*		$#error $@NOHOST $: Unrecognized host name $2')
641
642# if this is quoted, strip the quotes and try again
643R$+			$: $(dequote $1 $)		strip quotes
644R$+ $=O $+		$@ $>97 $1 $2 $3			try again
645
646# handle locally delivered names
647R$=L			$#_LOCAL_ $: @ $1			special local names
648R$+			$#_LOCAL_ $: $1			regular local names
649
650###########################################################################
651###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
652###########################################################################
653
654S5
655
656# if we have a "special dotted user", convert it back to the base name
657R$=D . *		$#_LOCAL_ $: $1
658R$=D . $+		$#_LOCAL_ $: $1 . *
659
660# prepend an empty "forward host" on the front
661R$+			$: <> $1
662
663ifdef(`LUSER_RELAY',
664`# send unrecognized local users to a relay host
665R< > $+ + $*		$: < $L . > $( user $1 $) + $2
666R< > $+			$: < $L . > $( user $1 $)	look up user
667R< $* > $+ <> $*	$: < > $2 $3			found; strip $L
668R< $* . > $+		$: < $1 > $2			strip extra dot')
669
670# handle plussed local names
671R< > $+ + $*		$#_LOCAL_ $@ $2 $: $1
672
673# see if we have a relay or a hub
674R< > $+			$: < $R > $1			try relay
675R< > $+			$: < $H > $1			try hub
676R< > $+			$@ $1				nope, give up
677R< $- : $+ > $+		$: $>95 < $1 : $2 > $3 < @ $2 >
678R< $+ > $+		$@ $>95 < $1 > $2 < @ $1 >
679ifdef(`MAILER_TABLE',
680`
681
682###################################################################
683###  Ruleset 90 -- try domain part of mailertable entry 	###
684###################################################################
685
686S90
687R$* <$- . $+ > $*	$: $1$2 < $(mailertable .$3 $@ $1$2 $@ $2 $) > $4
688R$* <$- : $+ > $*	$# $2 $@ $3 $: $4		check -- resolved?
689R$* < . $+ > $*		$@ $>90 $1 . <$2> $3		no -- strip & try again
690R$* < $* > $*		$: < $(mailertable . $@ $1$2 $) > $3	try "."
691R<$- : $+ > $*		$# $1 $@ $2 $: $3		"." found?
692R< $* > $*		$@ $2				no mailertable match',
693`dnl')
694
695###################################################################
696###  Ruleset 95 -- canonify mailer:host syntax to triple	###
697###################################################################
698
699S95
700R< > $*			$@ $1				strip off null relay
701R< $- : $+ > $*		$# $1 $@ $2 $: $3		try qualified mailer
702R< $=w > $*		$@ $2				delete local host
703R< $+ > $*		$#_RELAY_ $@ $1 $: $2		use unqualified mailer
704
705###################################################################
706###  Ruleset 98 -- local part of ruleset zero (can be null)	###
707###################################################################
708
709S98
710undivert(3)dnl
711#
712######################################################################
713######################################################################
714#####
715`#####			MAILER DEFINITIONS'
716#####
717######################################################################
718######################################################################
719undivert(7)dnl
720