A Sample sendmail Configuration File
Following is an example of the default main.cf file. Subsequent sections describe the syntax and semantics used in this file.
############################################################
#
#Sendmail configuration file for "MAIN MACHINES"
#
#You should install this file as /etc/mail/sendmail.cf
#if your machine is the main (or only) mail-relaying
#machine in your domain. Then edit the file to
#customize it for your network configuration.
#
#@(#)main.mc1.2497/06/05 SMI
#
###local info
# delete the following if you have no sendmailvars table
Lmmaildomain
# my official hostname
# You have two choices here. If you want the gateway machine to identify
# itself as the DOMAIN, use this line:
Dj$m
# If you want the gateway machine to appear to be INSIDE the domain, use:
#Dj$w.$m
# if you are using sendmail.mx (or have a fully-qualified hostname), use:
#Dj$w
# major relay mailer - typical choice is "ddn" if you are on the
# Defense Data Network (e.g. Arpanet or Milnet)
DMsmartuucp
# major relay host: use the $M mailer to send mail to other domains
DR ddn-gateway
CR ddn-gateway
# If you want to pre-load the "mailhosts" then use a line like
# FS /usr/lib/mailhosts
# and then change all the occurrences of $%y to be $=S instead.
# Otherwise, the default is to use the hosts.byname map if NIS
# is running (or else the /etc/hosts file if no NIS).
# valid top-level domains (default passes ALL unknown domains up)
CT arpa com edu gov mil net org
CT us de fr jp kr nz il uk no au fi nl se ca ch my dk ar
# options that you probably want on a mailhost:
# checkpoint the queue after this many recipients
OC10
# refuse to send tiny messages to more than these recipients
Ob10
#################################################
#
#General configuration information
# local domain names
#
# These can now be determined from the domainname system call.
# The first component of the NIS domain name is stripped off unless
# it begins with a dot or a plus sign.
# If your NIS domain is not inside the domain name you would like to have
# appear in your mail headers, add a "Dm" line to define your domain name.
# The Dm value is what is used in outgoing mail. The Cm values are
# accepted in incoming mail. By default Cm is set from Dm, but you might
# want to have more than one Cm line to recognize more than one domain
# name on incoming mail during a transition.
# Example:
# DmCS.Podunk.EDU
# Cm cs cs.Podunk.EDU
#
# known hosts in this domain are obtained from gethostbyname() call
# Version number of configuration file
#ident"@(#)version.m41.1792/07/14 SMI"/* SunOS 4.1*/
#
#
#Copyright Notice
#
#Notice of copyright on this source code product does not indicate
#publication.
#
#(c) 1986,1987,1988,1989 Sun Microsystems, Inc
# All rights reserved.
DVSMI-SVR4
### Standard macros
# name used for error messages
DnMailer-Daemon
# special user
CDMailer-Daemon root daemon uucp
# UNIX header format
DlFrom $g $d
# delimiter (operator) characters
Do.:%@!^=/[]
# format of a total name
Dq$g$?x ($x)$.
# SMTP login message
De$j Sendmail $v/$V ready at $b
### Options
# Remote mode - send through server if mailbox directory is mounted
OR
# Turn on the DNS name look up
OI
# location of alias file
OA/etc/mail/aliases
# default delivery mode (deliver in background)
Odbackground
# rebuild the alias file automagically
OD
# temporary file mode 0600 for secure mail, 0644 for permissive
OF0600
# default GID
Og1
# location of help file
OH/etc/mail/sendmail.hf
# log level
OL9
# default messages to old style
Oo
# Cc my postmaster on error replies I generate
OPPostmaster
# queue directory
OQ/var/spool/mqueue
# read timeout for SMTP protocols
Or15m
# status file none
OS/etc/mail/sendmail.st
# queue up everything before starting transmission, for safety
Os
# return queued mail after this long
OT3d
# default UID
Ou1
### Message precedences
Pfirst-class=0
Pspecial-delivery=100
Pjunk=-100
### Trusted users
T root daemon uucp
### Format of headers
H?P?Return-Path: <$g>
HReceived: $?sfrom $s $.by $j ($v/$V)
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:
H?M?Resent-Message-Id: <$t.$i@$j>
H?M?Message-Id: <$t.$i@$j>
HErrors-To:
###########################
### Rewriting rules ###
###########################
# Sender Field Pre-rewriting
S1
# None needed.
# Recipient Field Pre-rewriting
S2
# None needed.
# Name Canonicalization
# Internal format of names within the rewriting rules is:
# anything<@host.domain.domain...>anything
# We try to get every kind of name into this format, except for local
# names, which have no host part. The reason for the "<>" stuff is
# that the relevant host name could be on the front of the name (for
# source routing), or on the back (normal form). We enclose the one that
# we want to route on in the <>'s to make it easy to find.
#
S3
# handle "from:<>" special case
R$*<>$*$@ @turn into magic token
# basic textual canonicalization
R<$*<@$+>>$@$1<@$2>
R$*<$+>$*$2basic RFC822 parsing
# make sure <@a,@b,@c:user@d> syntax is easy to parse undone later
R@$+,$+:$+@$1:$2:$3change all","to":"
R@$+:$+$@$>6<@$1>:$2src route canonical
R$+:$*;@$+$@$1:$2;@$3list syntax
R$+@$+$:$1<@$2>focus on domain
R$+<$+@$+>$1$2<@$3>move gaze right
R$+<@$+>$@$>6$1<@$2>already canonical
# convert old-style names to domain-based names
# All old-style names parse from left to right, without precedence.
R$-!$+$@$>6$2<@$1.uucp>ucphost!user
R$-.$+!$+$@$>6$3<@$1.$2>ost.domain!user
R$+%$+$@$>3$1@$2user%host
# Final Output Post-rewriting
S4
R$+<@$+.uucp>$2!$1u@h.uucp => h!u
R$+$: $>9 $1Clean up addr
R$*<$+>$*$1$2$3defocus
# Clean up a name for passing to a mailer
# (but leave it focused)
S9
R$=w!@$@$w!$n
R@$@$nhandle <> error addr
R$*<$*LOCAL>$*$1<$2$m>$3change local info
R<@$+>$*:$+:$+<@$1>$2,$3:$4<route-addr> canonical
#######################
# Rewriting rules
# special local conversions
S6
R$*<@$*$=m>$*$1<@$2LOCAL>$4convert local domain
# Local and Program Mailer specification
Mlocal,P=/usr/lib/mail.local, F=flsSDFMmnP, S=10,R=20, A=mail.local -d $u
Mprog,P=/bin/sh, F=lsDFMeuP, S=10, R=20, A=sh -c $u
S10
# None needed.
S20
# None needed.
#ident"@(#)etherm.m41.1695/12/01 SMI"/* SunOS 4.1*/
#
#Copyright Notice
#
#Notice of copyright on this source code product does not indicate
#publication.
#
#(c) 1986,1987,1988,1989 Sun Microsystems, Inc
# All rights reserved.
############################################################
#####
#####Ethernet Mailer specification
#####
#####Messages processed by this configuration are assumed to remain
#####in the same domain. This really has nothing particular to do
#####with Ethernet - the name is historical.
Mether,P=[TCP], F=msDFMuCX, S=11, R=21, A=TCP $h, E=\r\n
S11
R$*<@$+>$*$@$1<@$2>$3already ok
R$=D$@$1<@$w>tack on my hostname
R$+$@$1<@$k>tack on my mbox hostname
S21
R$*<@$+>$*$@$1<@$2>$3already ok
R$+$@$1<@$k>tack on my mbox hostname
##########################################################
# General code to convert back to old style UUCP names
S5
R$+<@LOCAL>$@$w!$1name@LOCAL => sun!name
R$+<@$-.LOCAL>$@ $2!$1u@h.LOCAL => h!u
R$+<@$+.uucp>$@ $2!$1u@h.uucp => h!u
R$+<@$*>$@ $2!$1u@h => h!u
# Route-addrs do not work here. Punt til uucp-mail comes up with something.
R<@$+>$*$@ @$1$2just defocus and punt
R$*<$*>$*$@ $1$2$3Defocus strange stuff
#UUCP Mailer specification
Muucp,P=/usr/bin/uux, F=msDFMhuU, S=13, R=23,
A=uux - -r -a$f $h!rmail($u)
# Convert uucp sender (From) field
S13
R$+$:$>5$1convert to old style
R$=w!$+$2strip local name
R$+$:$w!$1stick on real host name
# Convert uucp recipient (To, Cc) fields
S23
R$+$:$>5$1convert to old style
#ident"@(#)ddnm.m41.893/06/30 SMI"/* SunOS 4.1*/
#
#
#Copyright Notice
#
#Notice of copyright on this source code product does not indicate
#publication.
#
#(c) 1986,1987,1988,1989 Sun Microsystems, Inc
# All rights reserved.
############################################################
#
#DDN Mailer specification
#
#Send mail on the Defense Data Network
# (such as Arpanet or Milnet)
Mddn,P=[TCP], F=msDFMuCX, S=22, R=22, A=TCP $h, E=\r\n
# map containing the inverse of mail.aliases
# Note that there is a special case mail.byaddr will cause reverse
# lookups in both Nis+ and NIS.
# If you want to use ONLY Nis+ for alias inversion comment out the next
line
# and uncomment the line after that
DZmail.byaddr
#DZREVERSE.mail_aliases.org_dir
S22
R$*<@LOCAL>$*$:$1
R$-<@$->$:$>3${Z$1@$2$}invert aliases
R$*<@$+.$*>$*$@$1<@$2.$3>$4already ok
R$+<@$+>$*$@$1<@$2.$m>$3tack on our domain
R$+$@$1<@$w.$m>tack on our full name
# "Smart" UUCP mailer: Uses UUCP transport but domain-style naming
Msmartuucp, P=/usr/bin/uux, F=CmsDFMhuU, S=22, R=22,
A=uux - -r $h!rmail ($u)
############################################################
#
#RULESET ZERO
#
#This is the ruleset that determines which mailer a name goes to.
# Ruleset 30 just calls rulesets 3 then 0.
S30
R$*$: $>3 $1First canonicalize
R$*$@ $>0 $1Then rerun ruleset 0
S0
# On entry, the address has been canonicalized and focused by ruleset 3.
# Handle special cases.....
R@$#local $:$nhandle <> form
# resolve the local hostname to "LOCAL".
R$*<$*$=w.LOCAL>$*$1<$2LOCAL>$4thishost.LOCAL
R$*<$*$=w.uucp>$*$1<$2LOCAL>$4thishost.uucp
R$*<$*$=w>$*$1<$2LOCAL>$4thishost
# Mail addressed explicitly to the domain gateway (us)
R$*<@LOCAL>$@$>30$1strip our name, retry
R<@LOCAL>:$+$@$>30$1retry after route strip
# For numeric spec, you can't pass spec on to receiver, since old rcvr's
# are not smart enough to know that [x.y.z.a] is their own name.
R<@[$+]>:$*$:$>9 <@[$1]>:$2Clean it up, then...
R<@[$+]>:$*$#ether $@[$1] $:$2numeric internet spec
R<@[$+]>,$*$#ether $@[$1] $:$2numeric internet spec
R$*<@[$+]>$#ether $@[$2] $:$1numeric internet spec
# deliver to known ethernet hosts explicitly specified in our domain
R$*<@$%y.LOCAL>$*$#ether $@$2$:$1<@$2>$3user@host.sun.com
# deliver to hosts in our domain that have an MX record
R$*<@$%x.LOCAL>$*$#ether $@$2 $:$1<@$2>$3user@host.sun.com
# etherhost.uucp is treated as etherhost.$m for now.
# This allows them to be addressed from uucp as foo!sun!etherhost!user.
R$*<@$%y.uucp>$*$#ether $@$2 $:$1<@$2>$3user@etherhost.uucp
# Explicitly specified names in our domain that we've never heard of
R$*<@$*.LOCAL>$*$#error $:Never heard of host $2 in domain $m
# Clean up addresses for external use kills LOCAL, route-addr ,=>:
R$*$:$>9 $1Then continue...
# resolve UUCP-style names
R<@$-.uucp>:$+$#uucp $@$1 $:$2@host.uucp:...
R$+<@$-.uucp>$#uucp $@$2 $:$1user@host.uucp
# Pass other valid names up the ladder to our forwarder
#R$*<@$*.$=T>$*$#$M$@$R $:$1<@$2.$3>$4user@domain.known
# Replace following with above to only forward "known" top-level domains
R$*<@$*.$+>$*$#$M$@$R $:$1<@$2.$3>$4 user@any.domain
# if you are on the DDN, then comment-out both of the lines above
# and use the following instead:
#R$*<@$*.$+>$*$#ddn $@ $2.$3 $:$1<@$2.$3>$4user@any.domain
# All addresses in the rules ABOVE are absolute (fully qualified domains).
# Addresses BELOW can be partially qualified.
# deliver to known ethernet hosts
R$*<@$%y>$*$#ether $@$2 $:$1<@$2>$3user@etherhost
# deliver to known ethernet hosts that have an MX record
R$*<@$%x>$*$#ether $@$2 $:$1<@$2>$3user@etherhost
# other non-local names have nowhere to go; return them to sender.
R$*<@$+.$->$*$#error $:Unknown domain $3
R$*<@$+>$*$#error $:Never heard of $2 in domain $m
R$*@$*$#error $:I don't understand $1@$2
# Local names with % are really not local!
R$+%$+$@$>30$1@$2turn % => @, retry
# everything else is a local name
R$+$#local $:$1local names