SENDMAIL.CF EXAMPLE FILE

###############################################################
# sendmail.cf   as discribed in "Customizing sendmail",
#              Sys Admin Magazine marts 1997
#              If used, file must be debugged with 
#              sendmail -bt -Cfilename with ruleset 3,0
#    to validate YOUR site configuration, 
#    before installation.
#
# Author:       Lars Magnusson
#               TUPILAQ Arctica Consultants
#               Lars.Magnusson@abc.se (for bugreports)
#
# Revision: 1.0 
# Date: 1996/11/18 
# Changes :
# xx.xx.xx:     xx
#       
###############################################################

# Our official canonical hostname.
Dj$w

# Type of relay to external smarthost, uucp, ether or smtp
DMsmtp

# This is the name of the smart host we deliver to
DRyoursmarthost
CR yoursmarthost

# My domain (excluding machine name for Dm)
Dmtv.com
Cm tv.com mycrate.tv.com mycrate

# Other names for the local host
Cw localhost 

# in domain, local on ether
CU myetherhost

# in domain on uucp
CV myuuhost

# friends outside domain on ether (excl top domain)
# can also be a machine in their domain (see ruleset 5 line 2 for beavis)
CW beavis snoopy

# friends outside domain on uucp (excl top domain)
# can also be a machine in their domain (see ruleset 5 line 2 for butthead)
CX butthead gloomy

# Version number of config file (incl. revisions)
DVSM sm.v8 (rev. sa1.0)

## Standard macros
# name used for error messages
DnMailer-Daemon
# UNIX header format
DlFrom $g $d
# seperator (operator) characters
Do.:%@!^=/[]
# format of a total name
Dq<$g>
# SMTP login message
De$j Sendmail $v/$V ready at $b

# Remote node
OR
# Localtion of aliases
OA/etc/aliases 
# Process messages in the background.
Odbackground
# Default permissions for files
OF0600
# Default user and group (daemon/daemon)
Og1
Ou1
# The logging level
OL9
# Accept oldstyle addresses
Oo
# Send a copy of bounced messages to postmaster
OPPostmaster
# SMTP read timeout
Or15m
# Note, we do queue, in case hub and MX's are all down.
OQ/var/spool/mqueue
# Queue up befor send
Os
# Time to live in the queue
OT3d

###   Message precedences (all of equal weight. let hub decide.)
Pfirst-class=0
Pspecial-delivery=100
Pjunk=-100

###   Trusted users
T root daemon uucp

## Required headers
HReceived: $?sfrom $s $.by $j ($v) 
     id $i; $b
H?F?Return-Path: $q
H?D?Date: $a
H?F?From: $q
H?M?Message-Id: <$t.$i@$j>
H?D?Resent-Date: $a
H?F?Resent-From: $q
H?M?Resent-Message-Id: <$t.$i@$j>
H?x?Full-Name: $x


#*********************************************************************
#
#  RULES
#

#*********************************************************************
# Ruleset 0
# Determin delivery form and deliver 
#*******************************
S0 

# We may want som special filters, like handle x.400 addresses
# Go there first before sending the letters off.
#
R$*                     $: $>5 $1                       First make any revisions

# Punt to hub 
R$*@$m                  $#local $:$1                    user@domain
R$*@$j                  $#local $:$1                    user@hub 
R$*@$=w                 $#local $:$1                    user@alias 
R$*@$=w.$m              $#local $:$1                    user@alias.domain

# uucp-connected crates in domain
# Presently camelot defined
R$*@$=V                 $#uucp $@$2 $:$1<@$m>           user@host 
R$*@$=V.$m              $#uucp $@$2 $:$1<@$m>   user@host.domain

# ether-connected crates in domain
# 
R$*@$=U                 $#ether $@$2 $:$1<@$m>          user@crate 
R$*@$=U.$m              $#ether $@$2 $:$1<@$m>          user@crate.domain

# External "friends" using ether
# See dummy beavis macro.  OBSERVE that last $* is top domain fx. ".com"
# Can also be to a crate in the domain, fx.  W="snoopy" in "snoopy.beavis.com"
R$*@$=W.$*              $#ether $@$2 $:$1<@$2.$3>       user@domain
R$*@$*.$=W.$*           $#ether $@$2 $:$1<@$2.$3.$4>  user@crate.domain 

# External "friends" using uucp
# See dummy butthead macro.  OBSERVE that last $* is top domain fx. ".com"
# Can also be to a crate in the domain, fx.  X="gloomy" in "gloomy.butthead.com"
R$*@$=X.$*              $#uucp $@$2 $:$1<@$2.$3>        user@domain
R$*@$*.$=X.$*           $#uucp $@$2 $:$1<@$2.$3.$4>   user@crate.domain 

# To smartmailer for non-local sites.  Can be the ISP.
R$*                     $#$M $@$R $:$1                  Mailer defined with DM

#********************************
# Ruleset 1
# Sender field pre-rewriting 
#********************************
S1
# not used presently

#********************************
# Ruleset 2 
# Recipient field pre-rewriting 
#********************************
S2
# not used presently

#********************************
# Ruleset 3 
# Sender addresses, some necessary rewrites of bad formated adresses.
#********************************
S3 

# local users made to look like they are from the hub
R$*<$*<$*>$*>$*         $3                      denest
R$*<$+>$*               $2                      basic RFC822 parsing
R$*<>$*                 $n                      RFC1123 <>
R$-                     $@ $1 @ $m              user => user@hub
#R$+@$+                 $: $1 @ $[$2$]          canonify the hostname
#R$+@$=w                $@ $1 @ $m              user@thishost => 
user@hub
#R$=w!$+                $@ $2 @ $m              thishost!user => 
user@hub
R$+%$=w                 $@ $>3 $1 @ $2          handle % hack 
thishost
R$*                     $@ $1                   default, unchanged

#********************************
# Ruleset 4 
# Final output post-rewriting
#********************************
S4
# not used yet                                          

#********************************
# Ruleset 5
# Major special case filter :-)
# If we communicate with any net with none domain addressing
# why not let users to write the recipients address as it
# looks and rewrite it here.  If the client and sendmail can
# handle it that is.  Here is some examples.
#********************************
S5

# Mail to other mail-nets, presently x400, memo and fido
# x400, identified by the use of equal sign "ADMD=400net"
R$*=$-@x400             $1=$2                           If x400 sent here, remove domain
R$*=$-@$m               $1=$2                           If x400 sent here, remove domain
R$*=$-@x400.$m          $1=$2                           If x400 sent here, remove domain
R$*=$-                  \"$1=$2\"@x400net.telia.com     Handle external x400

# memonet, a swedish MVS/VM mailer (as it used to be addressed from internet)
# now just an example.
R$-.$-.$-@memo          $1.$2.$3                        If memo sent here, remove
domain
R$-.$-.$-@memo.$m       $1.$2.$3                        If memo sent here, remove
domain
R$-.$-.$-               $1.$2.$3@memo.ericsson.se       still a Memo gateway for Ericsson



#*********************************************************************
#
#  Methods for delivery
#

#*********************************************************************
# Define local delivery

Mlocal,         P=/usr/bin/procmail, F=lsDFMAw5:/|@ShPfn, S=10/30, R=20/40,
          T=DNS/RFC822/X-Unix,
          A=procmail -a $h -d $u
Mprog,          P=/bin/sh, F=lsDFMoeu, S=10/30, R=20/40, D=$z:/,
          T=X-Unix,
          A=sh -c $u

#  Envelope sender rewriting
#
S10
R<@>                    $n                      errors to mailer-daemon
R$+                     $: $>50 $1              add local domain if needed

#  Envelope recipient rewriting
#
S20
R$+ < @ $* >            $: $1                   strip host part

#  Header sender rewriting
#
S30
R<@>                    $n                      errors to mailer-daemon
R$+                     $: $>50 $1              add local domain if needed

#  Header recipient rewriting
#
S40
R$+                     $: $>50 $1              add local domain if needed

#
#  Common code to add local domain name (only if always-add-domain)
#
S50
#R$* < @ $* > $*        $@ $1 < @ $2 > $3        already fully qualified
#R$+                    $@ $1 < @ *LOCAL* >          add local qualification


#**********************************************************************
#       UUCP Mailer specification
#

Muucp,  P=/usr/bin/uux, F=msDFMh, S=13/33, R=23,
     A=uux - -r $h!rmail ($u)


# Convert uucp sender (From) field (Envelope)
S13
R$=w!$+                 $2                              strip local name
R$=$m!$+                $2                              hide local machines
R$=$m.$+!$+             $:$2!$3                         Hide host
R$=V!$+                 $:$1.$j!$2                      if bang etherhost
R$=U!$+                 $:$1.$j!$2                      if bang uucphost
R$-                     $:$j!$1                     stick on real host name

# Convert uucp sender (From:) field (Letter)
S33
R$-                     $1@$m                           make From: domain

# Receiver address rewrite for uucp (Envelope+Letter)
S23
R$*<@$=w>$*             $1<@$w>$2                       resolve abbreviations
R$*<@$->$*              $1<@$2.$m>$3                    resolve abbreviations
R$+<@$w>                $U!$1                           a!b@here -> here!a!b
R$=U!$+                 $2                              here!a!b -> a!b
# sanity ... should not happen.
R$=U.$m!$+              $2                              strip local name.domain


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

Msmtp,          P=[IPC], F=mDFMuX, S=11/31, R=21, E=\r\n, L=990,
          T=DNS/RFC822/SMTP,
          A=IPC $h
Mesmtp,         P=[IPC], F=mDFMuXa, S=11/31, R=21, E=\r\n, L=990,
          T=DNS/RFC822/SMTP,
          A=IPC $h
Msmtp8,         P=[IPC], F=mDFMuX8, S=11/31, R=21, E=\r\n, L=990,
          T=DNS/RFC822/SMTP,
          A=IPC $h
Mrelay,         P=[IPC], F=mDFMuXa8, S=11/31, R=61, E=\r\n, L=2040,
          T=DNS/RFC822/SMTP,
          A=IPC $h
Mether,         P=[IPC], F=mDFMuCX, S=0, R=0, A=IPC $h

#
#  envelope sender rewriting
#
S11
R$+                     $: $>51 $1                      sender/recipient common
R$* :; <@>              $@                              list:; special case

#
#  envelope recipient rewriting --
#  also header recipient if not masquerading recipients
#
S21
R$+                     $: $>51 $1               sender/recipient common

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

# do special header rewriting
R$* <@> $*              $@ $1 <@> $2                    pass null host through
R< @ $* > $*            $@ < @ $1 > $2                  pass route-addr through

#  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

# do UUCP heuristics; note that these are shared with UUCP mailers
R$+ < @ $+ .UUCP. >     $: < $2 ! > $1                  convert to UUCP form
R$+ < @ $* > $*         $@ $1 < @ $2 > $3               not UUCP form

# leave these in .UUCP form to avoid further tampering
R< $&h ! > $- ! $+      $@ $2 < @ $1 .UUCP. >
R< $&h ! > $-.$+ ! $+   $@ $3 < @ $1.$2 >
R< $&h ! > $+           $@ $1 < @ $&h .UUCP. >
R< $+ ! > $+            $: $1 ! $2 < @ *LOCAL* >

