#
# Copyright (c) 1983 Eric P. Allman
# Copyright (c) 1988, 1993
#	The Regents of the University of California.  All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
#    must display the following acknowledgement:
#	This product includes software developed by the University of
#	California, Berkeley and its contributors.
# 4. Neither the name of the University nor the names of its contributors
#    may be used to endorse or promote products derived from this software
#    without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)proto	3.22 (motonori/WIDE) 4/18/94
#%REVISION_ID_LIST%

############################################################################
############################################################################
#####
#####		SENDMAIL CONFIGURATION FILE
#####			for R8 sendmail
#####
#%WHO%
#%WHERE%
#%WHAT%
#%WHEN%
#####
############################################################################
############################################################################
#%CHAR_ALLOCATION_LIST%

# level 5 config file format
V5

#########################
#   Local Information   #
#########################

# local domain name (defined automatically)
#%MACRO_m%

# local host name without domain (defined automatically)
#%MACRO_w%

# my official SMTP hostname (defined automatically)
#%MACRO_j%

# my internet aliases
#%FILECLASS_w%
#%CLASS_w%

#%HDRUUNAME%
#%HDRACCEPTADDR%
#%HDRACCEPTLOWER%

# users who require host.domain
#%HDRLOCALUSERS%

# default from-address (can be $j, $m or another generic address)
#%HDRFROMADDR%

#%HDRSPOOLHOST%
#%HDRSPECIALFROM%
#%HDRSECONDARY%
#%HDRHUBHOST%
#%HDRINDIRECTRELAY%
#%HDRROUTE%
#%HDRSTATIC%
#%HDRDOMAINTABLE%
#%HDRMAILERTABLE%
#%HDRUSERTABLE%
#%HDRNISLOOKUP%
#%HDRNEWS%
#%HDRLOCALHACK%
#%ESMTPPEERS%
#%IDENTPEERS%

# operators that cannot be in local usernames (i.e., network indicators)
C@ @ % !

# dequoting map
Kdequote dequote

#############################
###   Setup Information   ###
#############################

######################
#   General Macros   #
######################

#%HDRUUCP%
#%HDRBITNET%
#%HDRDECNET%

#%MXDOTTERMINATE%

###############
#   Classes   #
###############

# Internal ("fake") domains that we use in rewriting
#%FAKEUUCP%
#%FAKEDOMAIN%
# and special terminators
#%TERMINATORS%
#%KNOWNDOMAINS%

######################
#   Version Number   #
######################

#%VERSION%

######################
#   Special macros   #
######################

# my name
#%MACRO_n%
# UNIX header format
#%MACRO_l%
# delimiter (operator) characters
#%MACRO_o%
# format of a total name
#%MACRO_q%
# SMTP login message
#%MACRO_e%

###############
#   Options   #
###############

# strip message body to 7 bits on input?
#%OPTION_7%
# location of alias file
#%OPTION_A%
# wait (in minutes) for alias file rebuild
#%OPTION_a%
# substitution for space (blank) characters
#%OPTION_B%
# minimum number of free blocks on filesystem
#%OPTION_b%
# checkpoint queue runs after every N successful deliveries
#%OPTION_C%
# connect to "expensive" mailers on initial submission?
#%OPTION_c%
# automatically rebuild the alias database?
#%OPTION_D%
# default delivery mode
#%OPTION_d%
# error message header/file */
#%OPTION_E%
# error mode
#%OPTION_e%
# temporary file mode
#%OPTION_F%
# save Unix-style "From_" lines at top of header?
#%OPTION_f%
# match recipients against GCOS field?
#%OPTION_G%
# default GID
#%OPTION_g%
# location of help file
#%OPTION_H%
# maximum hop count
#%OPTION_h%
# Insist that the BIND name server be running to resolve names
#%OPTION_I%
# ignore dots as terminators in incoming messages?
#%OPTION_i%
# Forward file search path
#%OPTION_J%
# deliver MIME-encapsulated error messages?
#%OPTION_j%
# open connection cache timeout
#%OPTION_K%
# open connection cache size
#%OPTION_k%
# log level
#%OPTION_L%
# use Errors-To: header?
#%OPTION_l%
# send to me too, even in an alias expansion?
#%OPTION_m%
# verify RHS in newaliases?
#%OPTION_n%
# SMTP daemon options
#%OPTION_O%
# default messages to old style headers if no special punctuation?
#%OPTION_o%
# who (if anyone) should get extra copies of error messages
#%OPTION_P%
# privacy flags
#%OPTION_p%
# queue directory
#%OPTION_Q%
# slope of queue-only function
#%OPTION_q%
# do not strip route address of error receiver
#%OPTION_R%
# read timeout -- now OK per RFC 1123 section 5.3.2
#%OPTION_r%
# status file
#%OPTION_S%
# queue up everything before forking?
#%OPTION_s%
# default message timeout interval
#%OPTION_T%
# time zone handling:
#  if undefined, use system default
#  if defined but null, use TZ envariable passed in
#  if defined and non-null, use that info
#%OPTION_t%
# list of locations of user database file (null means no lookup)
#%OPTION_U%
# default UID
#%OPTION_u%
# fallback MX host
#%OPTION_V%
# if we are the best MX host for a site, try it directly instead of config err
#%OPTION_w%
# load average at which we refuse connections
#%OPTION_X%
# load average at which we just queue messages
#%OPTION_x%
# deliver each queued job in a separate process?
#%OPTION_Y%
# work recipient factor
#%OPTION_y%
# work time factor
#%OPTION_Z%
# work class factor
#%OPTION_z%


###########################
#   Message precedences   #
###########################

Pfirst-class=0
Pspecial-delivery=100
Plist=-30
Pbulk=-60
Pjunk=-100

#####################
#   Trusted users   #
#####################

Troot daemon uucp
#%TRUSTDEF%

#########################
#   Format of headers   #
#########################

H?P?Return-Path: $g
#%FMTRECEIVED%
H?D?Resent-Date: $a
H?D?Date: $a
H?F?Resent-From: $q
H?F?From: $q
H?x?Full-Name: $x
HSubject:
# HPosted-Date: $a
# H?l?Received-Date: $b
H?M?Resent-Message-Id: <$t.$i@$j>
H?M?Message-Id: <$t.$i@$j>


######################################################################
######################################################################
#####
#####			REWRITING RULES
#####
######################################################################
######################################################################

################################################
###  Rulset 1 -- Sender Field Pre-rewriting  ###
################################################
S1
#%S1STRIPTRAILINGDOT%
#%S1LOCALHACKRULE%

###################################################
###  Rulset 2 -- Recipient Field Pre-rewriting  ###
###################################################
S2
#%S2STRIPTRAILINGDOT%
#%S2LOCALHACKRULE%

###########################################
###  Rulset 3 -- Name Canonicalization  ###
###########################################
S3

# handle null input and list syntax (translate to <@> special case)
R$@			$@<@>

# basic textual canonicalization -- note RFC733 heuristic here
R$*<$*>$*<$*>$*		$2$3<$4>$5			strip multiple <> <>
R$*<$*<$*<$+>$*>$*>$*	$4				3-level <> nesting
R$*<$*<$+>$*>$*		$3				2-level <> nesting
R$*<>$*			$@<@>				MAIL FROM: <> case
R$*<$+>$*		$2				basic RFC821/822 parsing

# This may be useful to use with 'rmail'.
# Hoping that we do not have such a uucp host name like 'somewhere'.
#Rsomewhere!$+		$1				strip 'somewhere!'

#%S3LOCALHACK_FOCUS%

# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
R@$+,$+			@$1:$2				change all "," to ":"

# localize and dispose of route-based addresses
R@$+:$+			$@$>96 <@$1>:$2			handle <route-addr>

# find focus for list syntax
R$+:$*;@$+		$@$1:$2;<@$3>			list syntax
R$+:$*;			$@$1:$2;<@>			list syntax

# find focus for @ syntax addresses
R$+@$+			$:$1<@$2>			focus on domain
R$+<$+@$+>		$1$2<@$3>			move gaze right
R$+<@$+>		$@$>96 $1<@$2>			already canonical

# do some sanity checking
R$*<@$*:$*>$*		$1<@$2$3>$4			nix colons in addrs

#%S3LOCALHACK_NO_AT%
#%EXTENDEDUUCPCONV%
# convert old-style addresses to a domain-based address
R$-!$+			$@$>96 $2<@$1.UUCP>		resolve uucp names
R$+.$-!$+		$@$>96 $3<@$1.$2>		domain uucps
R$+.!$+			$@$>96 $2<@$1>			extended domain uucps
R$*!$*			$@$>96 $2<@$1.UUCP>		uucp subdomains

# if we have % signs, take the rightmost one
R$+%$+			$1@$2				First make them all @s.
R$+@$+@$+		$1%$2@$3			Undo all but the last.
R$+@$+			$@$>96 $1<@$2>			Insert < > and finish

# trap invalid address
R@$*			$@<@$1>

################################################
###  Ruleset 96 -- bottom half of ruleset 3  ###
################################################

#  At this point, everything should be in a "local_part<@domain>extra" format.
S96

# strip trailing dot off
R$*<@$+.>$*		$1<@$2>$3

#%RESRULE%
#%ALIASRULE%
#%DOMAINTABLERULE%

R$*<@$=w.UUCP>$*	$:$1<@$j>$3
R$*<@$=w.$m>$*		$:$1<@$j>$3
R$*<@$=w>$*		$:$1<@$j>$3
#%LOCALHACK_LOCALIZE%

#%UUCPRESRULE%
# exit immidiately, if fake domains or numeric address spec
R$*<@$*.$=X>$*		$@$1<@$2.$3>$4

#%CANONACCEPTADDR%
#%CANONACCEPTLOWER%
#%CANONRULE1%
#%CANONRULE2%
#%CANONRULE3%
#%CANONRULE4%
#%CANONRULE5%
#%STRIPTRAILINGDOT%

##################################################
###  Ruleset 4 -- Final Output Post-rewriting  ###
##################################################
S4

R<>			$@<>				handle <> for uucp
R<@>			$@<>				catch invalid address
R$*<@>			$@$1				handle <> and list:;

#%S4LOCALHACK%

# strip trailing dot off possibly canonical name
R$*<@$+.>$*		$1<@$2>$3

# externalize local domain info
R$*<$+>$*		$1$2$3				defocus
R@$+:@$+:$+		@$1,@$2:$3			<route-addr> canonical
R@$*			$@@$1				... and exit

# UUCP must always be presented in old form
R$+@$+.UUCP		$2!$1				u@h.UUCP => h!u

# delete duplicate local names
R$+%$=w@$j		$1@$j				u%host@host => u@host
#%S4ACCEPTADDR%

############################################################
###  Ruleset 97 -- recanonicalize and call ruleset zero  ###
###                (used for recursive calls)            ###
############################################################

S97

R$*			$:$>3 $1			canonicalize
#%LOCALHUBRETRYRULE%
R$*			$:$>0 $1			and try again

####################################
###  Ruleset 0 -- Parse Address  ###
####################################

S0

R$*<@>			$#local$:<>			special case error msgs
R<@$+>			$#error$@USAGE$: user address required

#%S0LOCALHUBRULE%
#%S0CANONRULE%
#%S0STRIPTRAILINGDOT%
#%S0LOCALHACK_NUMERIC%
#%NUMERICRULE%
#%S0LOCALHACK_ALIAS%
#%S0ALIASRULE%
#%ROUTERULE%
#%S0MAILERTABLE%
#%SPECIALFROMRULE%
#%SECONDARYRULE%
#%S0USERTABLEMAILDROP%
#%STICKYRULE%
#%S0LOCALHACK_RESOLV%

# now delete the local info
R$*<@>$*		$@$>97 $1			user@ => user
R<@$j>:$*		$@$>97 $1			@here:... -> ...
R$*<@$j>		$@$>97 $1			...@here -> ...
#%S0ACCEPTADDR%
#%S0ACCEPTLOWER%
#%S0LOCALHACK_ACCEPT%
#%REDIRECTRULE%
#%STATICRULE%
#%S0UUCPRULE%
#%BITNETRULE%
#%DECNETRULE%
#%JUNETRULE%
#%REJECTONERULE%
#%S0LOCALHACK_DELIVERY%
#%NISLOOKUPDELIVERRULE%
#%SMTPDELIVERRULE%

# if this is quoted, strip the quotes and try again
R$+			$:$(dequote $1 $)		strip quotes
R$+$=@$+		$@$>97 $1$2$3			try again
#%DECNETRULE%

# remaining names must be local
#%S0LOCALHACK_LOCAL%
#%S0NEWSRULE%
#%S5LOCALHUBRULE%
#%S5USERTABLEMAILDROP%
#%ADMINSTICKYRULE%
R$*			$#local$:$1			regular names

#########################################################################
###  Ruleset 5 -- special rewriting after aliases have been expanded  ###
#########################################################################

S5

#%HUBHOSTRULE%
#%SPOOLHOSTRULE%

##############################################
###  Ruleset 88 -- dispatching to mailers  ###
##############################################

S88

R<>:$*			$@$1				strip off null relay
R<$-:>:$*		$@$2				strip off null relay
#%IGNOREMXNUMERIC%
R<$=w>:$*		$@$2				delete local host
R<$-:$=w>:$*		$@$3				delete local host
#%DSPTLOCALHACK%
#%DSPTERRORRULE%
#%DSPTACCEPTRULE%
#%DSPTACCEPTLOWER%
R<smtp-ignmx>:$*<@$*>$*	$#smtp$@[$2]$:$1<@$2>$3		deliver w/o MX lookup
R<relay:$*$~X>:$*	$#relay$@$1$2$X$:$3		send to relay
R<smtp:$*$~X>:$*	$#smtp$@$1$2$X$:$3		send to destination
R<esmtp:$*$~X>:$*	$#esmtp$@$1$2$X$:$3		send to destination
R<$-:$+>:$*		$#$1$@$2$:$3			with specific mailer
#%DSPTUUCPRULE%
R<$*$~X>:$*		$#smtp$@$1$2$X$:$3		multi-token: smtp
R<$+>:$*		$#smtp$@$1$:$2			multi-token: smtp

#%MAILERTABLEBODY%

######################################################################
######################################################################
#####
#####			MAILER DEFINITIONS
#####
######################################################################
######################################################################


#%LOCALMAILER%
#%PROGMAILER%

#%SMTPMAILER%
#%ESMTPMAILER%
#%RELAYMAILER%

#%UUCPMAILER%
#%NEWSMAILER%

#%LOCALHACKMAILER%

##############################
#   Sender field rewriting   #
##############################

S10
R<@>			$n				errors to mailer-daemon
#%S10LOCALRULE%

S11
#%S11UUCPRULE%
#%S11SPECIALREWRITE%
#%S11SPECIALREWRITE2%
#%S11USERTABLEMAILNAME1%
#%S11GENERICREWRITE%
R$*<@$*>$*		$@$1<@$2>$3			already qualified

# output local host as user@host.domain
#%S11SPECIALFROM%
#%LOCALFROM%
#%S11SECONDARY%
#%S11USERTABLEMAILNAME2%
#%GENERALFROM%

#%SENDERUUCPRULE%
#%SENDERLOCALHACKRULE%

##################################
#   Receipient field rewriting   #
##################################

S20
R$+<@$*>		$:$1				strip host part
#%S20LOCALRULE%

S21

R$+<@$+.UUCP>		$@$2!$1				user@host.UUCP
#%S21SPECIALREWRITE%
#%S21SPECIALREWRITE2%
#%S21GENERICREWRITE%
R$*<@$*>$*		$@$1<@$2>$3			already qualified

# output local host as user@host.domain
#%S21SPECIALFROM%
#%LOCALFROM%
#%S21SECONDARY%
#%S21USERTABLEMAILNAME%
#%LOCALRECEIPIENTRULE%

#%S29RELAYRULE%
#%RECIPIENTUUCPRULE%
#%RECIPIENTLOCALHACKRULE%
