######################################################################
#####
#####		SENDMAIL CONFIGURATION FILE
#####
##### built by chuan@alpha2 on Sat Oct 29 22:12:28 CST 1994
#####
##### modified by jhlin@cs and chuan@cs for BBS E-mail service
#####
######################################################################

#####  @(#)cf.m4	8.4 (Berkeley) 12/24/93  #####

#####  @(#)tcpproto.mc	8.2 (Berkeley) 8/21/93  #####

#####  @(#)nouucp.m4	8.1 (Berkeley) 6/7/93  #####

#####  @(#)notsticky.m4	8.1 (Berkeley) 6/7/93  #####

#####  @(#)proto.m4	8.45 (Berkeley) 3/4/94  #####

# level 5 config file format
V5

##################
#   local info   #
##################

# Forced defind the FQDN and Domain
Djbbs.cs.nthu.edu.tw
Dwbbs
Dmcs.nthu.edu.tw

Cwlocalhost
# file containing names of hosts for which we receive email
Fw/etc/sendmail.cw

CP.

# "Smart" relay host (may be null)
DSesmtp:cs.nthu.edu.tw

# who I send unqualified names to (null means deliver locally)
DR

# who gets all local email traffic ($R has precedence for unqualified names)
DH

# who I masquerade as (null for no masquerading)
DM

# class L: names that should be delivered locally, even if we have a relay
# class E: names that should be exposed as from this host, even if we masquerade
#CLroot
CEroot

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

# a class with just dot (for identifying canonical names)
C..

# dequoting map
Kdequote dequote

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

# SMTP initial login message
De$j $?r$r $.ready at $b

# UNIX initial From header format
DlFrom $g  $d

# my name for error messages
DnMAILER-DAEMON

# delimiter (operator) characters
Do.:%@!^/[]

# format of a total name
Dq$?x$x <$g>$|$g$.

# Configuration version number
DZMapleBBS


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

# strip message body to 7 bits on input?
O7False

# wait (in minutes) for alias file rebuild
Oa10

# location of alias file
OA/etc/aliases

# minimum number of free blocks on filesystem
Ob4

# substitution for space (blank) characters
OB.

# avoid connecting to "expensive" mailers on initial submission?
OcFalse

# checkpoint queue runs after every N successful deliveries
OC10

# default delivery mode
Odbackground

# automatically rebuild the alias database?
ODFalse

# error message header/file
#OE/etc/sendmail.oE

# error mode
#Oep

# save Unix-style "From_" lines at top of header?
OfFalse

# temporary file mode
OF0600

# match recipients against GECOS field?
OGFalse

# default GID
Og1

# maximum hop count
Oh17

# location of help file
OH/usr/lib/sendmail.hf

# ignore dots as terminators in incoming messages?
OiFalse

# Insist that the BIND name server be running to resolve names
OI-DNSRCH
#OI

# deliver MIME-encapsulated error messages?
OjFalse

# Forward file search path
#OJ/var/forward/$u:$z/.forward.$w:$z/.forward

# open connection cache size
Ok1

# open connection cache timeout
OK5m

# use Errors-To: header?
OlFalse

# log level
OL4

# send to me too, even in an alias expansion?
OmTrue

# verify RHS in newaliases?
OnTrue

# default messages to old style headers if no special punctuation?
OoTrue

# SMTP daemon options
#OOPort=esmtp

# privacy flags
Opauthwarnings needmailhelo noexpn novrfy

# who (if anyone) should get extra copies of error messages
#OPPostmaster

# slope of queue-only function
#Oq600000

# queue directory
OQ/var/spool/mqueue

# read timeout -- now OK per RFC 1123 section 5.3.2
#Ordatablock=10m

# queue up everything before forking?
OsTrue

# status file
OS/etc/sendmail.st

# default message timeout interval
OT0h

# 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
#Ot

# default UID
#Ou1
Ou65534

# list of locations of user database file (null means no lookup)
#OU/etc/sendmail.user.db

# fallback MX host
#OVfall.back.host.net

# if we are the best MX host for a site, try it directly instead of config err
#OwFalse
OwTrue

# load average at which we just queue messages
Ox15

# load average at which we refuse connections
OX20

# work recipient factor
#Oy30000

# deliver each queued job in a separate process?
OYFalse

# work class factor
#Oz1800

# work time factor
#OZ90000

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

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

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

Troot
Tdaemon
Tuucp
Tbbs

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

H?P?Return-Path: $g
HReceived: $?_from $_ $.by $j$?r with $r$. id $i; $b
# 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 3 -- Name Canonicalization  ###
###########################################
S3

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

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

# handle list:; syntax as special case
R$*:;$*			$@ $1 :; <@>

# 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 $+ : $* ; @ $+	$@ $>96 $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


# 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

# else we must be a local name


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

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

# handle special cases for local names
R$* < @ localhost > $*		$: $1 < @ $j . > $2		no domain at all
R$* < @ localhost . $m > $*	$: $1 < @ $j . > $2		local domain
R$* < @ [ $+ ] > $*		$: $1 < @@ [ $2 ] > $3		mark [a.b.c.d]
R$* < @@ $=w > $*		$: $1 < @ $j . > $3		self-literal
R$* < @@ $+ > $*		$@ $1 < @ $2 > $3		canon IP addr

# pass to name server to make hostname canonical
#R$* < @ $* $~P > $*		$: $1 < @ $[ $2 $3 $] > $4

# local host aliases and pseudo-domains are always canonical
R$* < @ $=w > $*		$: $1 < @ $2 . > $3
R$* < @ $* $=P > $*		$: $1 < @ $2 $3 . > $4
R$* < @ $* . . > $*		$1 < @ $2 . > $3

# if this is the local hostname, make sure we treat is as canonical
R$* < @ $j > $*			$: $1 < @ $j . > $2


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

R$*<@>			$@ $1				handle <> and list:;

# 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


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



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

S97
R$*			$: $>3 $1
R$*			$@ $>0 $1


######################################
###   Ruleset 0 -- Parse Address   ###
###   modified for BBS user mail   ###
######################################

S0

R<@>			$#local $: <>			special case error msgs
R$* : $* ;		$#error $@ USAGE $: "list:; syntax illegal for recipient addresses"
R<@ $+>			$#error $@ USAGE $: "user address required"
R<$* : $* >		$#error $@ USAGE $: "colon illegal in host name part"

# handle numeric address spec
#R$* < @ [ $+ ] > $*	$: $>98 $1 < @ [ $2 ] > $3	numeric internet spec
#R$* < @ [ $+ ] > $*	$#smtp $@[$2]$: $1< @[$2] > $3	still numeric: send

# now delete the local info -- note $=O to find characters that cause forwarding
R$* < @ > $*		$@ $>97 $1			user@ => user
R< @ $=w . > : $*	$@ $>97 $2			@here:... -> ...
R$* $=O $* < @ $=w . >	$@ $>97 $1 $2 $3		...@here -> ...

# handle local hacks
R$*			$: $>98 $1
Rbbs < @ $=w . >	$#mailpost $: bbs		mailpost for bbs 
R$+.bbs < @ $=w .>	$#bbsmail $: $1			bbs mail gateway

# short circuit local delivery so forwarded email works
R$=L < @ $=w . >	$#local $: @ $1			special local names
R$+ < @ $=w . >		$#local $: $1			dispose directly
#R$+ < @ $=w . >		$: $1 < @ $2 @ $H >		first try hub
#R$+ < $+ @ $+ >		$#local $: $1			yep ....
#R$+ < $+ @ >		$#local $: @ $1			nope, local address

# resolve fake top level domains by forwarding to other hosts

# pass names that still have a host to a smarthost (if defined)
R$* < @ $* > $*		$: $>95 < $S > $1 < @ $2 > $3	glue on smarthost name

# deal with other remote names
R$* < @$* > $*		$#smtp $@ $2 $: $1 < @ $2 > $3	user@host.domain

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

# everything else is a local name
Rbbs			$#mailpost $:bbs
R$+.bbs			$#bbsmail $:$1			bbs mail gateway

# handle locally delivered names
R$=L			$#local $: @ $1			special local names
R$++$*			$#local $@$2 $: $1		regular local names
R$+			$#local $: $1			regular local names

###########################################################################
###   Ruleset 5 -- special rewriting after aliases have been expanded   ###
###		   (new sendmail only)					###
###########################################################################

S5

# see if we have a relay or a hub
R$+			$: < $R > $1			try relay
R< > $+			$: < $H > $1			try hub
R< > $+			$@ $1				nope, give up
R< $- : $+ > $+		$: $>95 < $1 : $2 > $3 < @ $2 >
R< $+ > $+		$@ $>95 < $1 > $2 < @ $1 >

###################################################################
###  Ruleset 95 -- canonify mailer:host syntax to triple	###
###################################################################

S95
R< > $*			$@ $1				strip off null relay
R< $- : $+ > $*		$# $1 $@ $2 $: $3		try qualified mailer
R< $=w > $*		$@ $2				delete local host
R< $+ > $*		$#relay $@ $1 $: $2		use unqualified mailer

###################################################################
###  Ruleset 98 -- local part of ruleset zero (can be null)	###
###################################################################

S98
#
######################################################################
######################################################################
#####
#####			MAILER DEFINITIONS
#####
######################################################################
######################################################################


##################################################
###   Local and Program Mailer specification   ###
##################################################

#####  @(#)local.m4	8.6 (Berkeley) 10/24/93  #####

#Mlocal,	P=/bin/mail, F=lsDFMrmn, S=10, R=20/40,
#		A=mail -d $u
Mlocal,		P=/usr/local/bin/procmail, F=lsSDFMhPfn, S=10, R=20/40,
		A=procmail -a $h -d $u
Mprog,		P=/bin/sh, F=lsDFMeu, S=10, R=20/40, D=$z:/,
		A=sh -c $u
Mmailpost,	P=/home/bbs/bin/mailpost, F=lsSDFMhPu, U=bbs, S=10, R=20/40,
		A=mailpost $u
Mbbsmail,	P=/home/bbs/bin/bbsmail, F=lsSDFMhPu, U=bbs, S=10, R=20/40,
		A=bbsmail $u

S10
R<@>			$n			errors to mailer-daemon
R$+			$: $>40 $1

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

S40

#####################################
###   SMTP Mailer specification   ###
#####################################

#####  @(#)smtp.m4	8.15 (Berkeley) 2/14/94  #####

Msmtp,		P=[IPC], F=mDFMuX, S=11/31, R=21, E=\r\n,
		L=990, A=IPC $h
Mesmtp,		P=[IPC], F=mDFMuXa, S=11/31, R=21, E=\r\n,
		L=990, A=IPC $h
Mrelay,		P=[IPC], F=mDFMuXa, S=11/31, R=61, E=\r\n,
		L=2040, A=IPC $h

#
#  envelope sender and masquerading recipient rewriting
#
S11
R$+			$: $>51 $1			sender/recipient common
R$* :; <@>		$@ $1 :;			list:; special case
R$*			$@ $>61 $1			qualify unqual'ed names

#
#  header recipient rewriting if not masquerading recipients
#
S21

# do sender/recipient common rewriting
R$+			$: $>51 $1

# unqualified names (e.g., "eric") are qualified by local host
R$* < @ $* > $*		$@ $1 < @ $2 > $3		already qualified
R$+			$: $1 < @ $j >			add local domain

#
#  header sender and masquerading recipient rewriting
#
S31
R$+			$: $>51 $1			sender/recipient common
R$* :; <@>		$@ $1 :;			list:; special case

# do special header rewriting
R$* <@> $*		$@ $1 <@> $2			pass null host through
R< @ $* > $*		$@ < @ $1 > $2			pass route-addr through
R$=E < @ $=w . >	$@ $1 < @ $2 >			exposed user as is
R$* < @ $=w . >		$: $1 < @ $2 @ $M >		masquerade as domain
R$* < @ $+ @ >		$@ $1 < @ $2 >			in case $M undefined
R$* < @ $+ @ $+ >	$@ $1 < @ $3 >			$M is defined -- use it
R$*			$@ $>61 $1			qualify unqual'ed names

#
#  convert pseudo-domain addresses to real domain addresses
#
S51

# pass <route-addr>s through
R< @ $+ > $*		$@ < @ $1 > $2			resolve <route-addr>

# output fake domains as user%fake@relay

#
#  common sender and masquerading recipient rewriting
#
S61

R$* < @ $* > $*		$@ $1 < @ $2 > $3		already qualified
R$=E			$@ $1 < @ $j>			show exposed names
R$+			$: $1 < @ $M >			user w/o host
R$+ <@>			$: $1 < @ $j >			in case $M undefined

#########################################################################
###  End of file
#########################################################################
