Configuring sendmail

Configuring sendmail is generally complex and complicated because it's a complicated program that does complex things. With simplicity, functionalty is frequently sacrificed which is not desireable for a mail server.

sendmail.cf

The sendmail distribution containts a directory called 'cf' where you will find all the tools necessary to build a sendmail.cf file.
# pwd
/home/source/sendmail-8.9.1a
# cd cf
# ls
README      domain      hack        mailer      sh
cf          feature     m4          ostype      siteconfig
# cd cf
# ls
Build                   generic-hpux10.cf       huginn.cs.mc
Makefile                generic-hpux10.mc       knecht.mc
chez.cs.mc              generic-hpux9.cf        mail.cs.mc
clientproto.mc          generic-hpux9.mc        mail.eecs.mc
cs-hpux10.mc            generic-nextstep3.3.mc  mailspool.cs.mc
cs-hpux9.mc             generic-osf1.cf         python.cs.mc
cs-osf1.mc              generic-osf1.mc         s2k-osf1.mc
cs-solaris2.mc          generic-solaris2.cf     s2k-ultrix4.mc
cs-sunos4.1.mc          generic-solaris2.mc     tcpproto.mc
cs-ultrix4.mc           generic-sunos4.1.cf     ucbarpa.mc
cyrusproto.mc           generic-sunos4.1.mc     ucbvax.mc
generic-bsd4.4.cf       generic-ultrix4.cf      uucpproto.mc
generic-bsd4.4.mc       generic-ultrix4.mc      vangogh.cs.mc
#
generally, the 'generic-XX.mc' files are good enough to get started on, and they are pretty easy to change. You'll note the lack of a linux generic file, but they are very easy to create. Here are some of my config files from a large mail server that has many end users using it to sendmail and recieve mail.

cf/mailserver.mc

divert(-1)
#
# Copyright (c) 1998 Sendmail, Inc.  All rights reserved.
# Copyright (c) 1983 Eric P. Allman.  All rights reserved.
# Copyright (c) 1988, 1993
#       The Regents of the University of California.  All rights reserved.
#

divert(0)dnl
VERSIONID(`@(#)mailserver.mc       8.8 (nikm) 8/4/98')
OSTYPE(linux)dnl
DOMAIN(sample.org)dnl
FEATURE(smrsh, /usr/sbin/smrsh)dnl
MAILER(local)dnl
MAILER(smtp)dnl
FEATURE(nouucp)dnl
FEATURE(rbl)dnl
FEATURE(relay_based_on_MX)dnl
FEATURE(local_procmail, /usr/bin/procmail)dnl
FEATURE(access_db, btree /etc/mail/access)dnl
FEATURE(genericstable, btree /etc/mail/genericstable)dnl
FEATURE(virtusertable, btree /etc/mail/virtusertable)dnl
define(`confSMTP_LOGIN_MSG',`$j Conjungi E-Mail  $b')dnl
define(`STATUS_FILE',/etc/mail/sendmail.st)dnl
define(`ALIAS_FILE',/etc/mail/aliases)dnl
define(`confCW_FILE',/etc/mail/sendmail.cw)dnl
define(`confCOPY_ERRORS_TO',postmaster)dnl
define(`confEBINDIR', /usr/lib/sm.bin)dnl

domain/sample.org.m4

divert(-1)
#
# Copyright (c) 1998 Sendmail, Inc.  All rights reserved.
# Copyright (c) 1983 Eric P. Allman.  All rights reserved.
# Copyright (c) 1988, 1993
#       The Regents of the University of California.  All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#

divert(0)
VERSIONID(`@(#)sample.m4      8.9 (nikm) 8/4/98')
define(`confFORWARD_PATH', `$z/.forward.$w+$h:$z/.forward+$h:$z/.forward.$w:$z/.forward')dnl
FEATURE(redirect)dnl
FEATURE(use_cw_file)dnl
define(`confLOG_LEVEL',0)dnl
define(`confPRIVACY_FLAGS', `authwarnings noexpn novrfy needmailhelo')dnl

ostype/linux.m4

divert(-1)
#
# Copyright (c) 1998 Sendmail, Inc.  All rights reserved.
# Copyright (c) 1983 Eric P. Allman.  All rights reserved.
# Copyright (c) 1988, 1993
#       The Regents of the University of California.  All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#

divert(0)
VERSIONID(`@(#)linux.m4 8.7c (nikm) 8/4/98')
define(`LOCAL_MAILER_PATH', /usr/bin/procmail)dnl
define(`LOCAL_MAILER_ARGS', procmail -a $h -d $u)dnl
define(`ALIAS_FILE', /etc/mail/aliases)dnl
define(`confCW_FILE', /etc/mail/sendmail.cw)
ifdef(`STATUS_FILE',, `define(`STATUS_FILE', /etc/mail/sendmail.st)') 
Once these files are all updated/created, in the cf/cf directory run:
m4 ../m4/cf.m4 mailserver.mc > sendmail.cf
I think install this file in /etc/mail and create a symlink from /etc/sendmail.cf to it.
# mkdir /etc/mail
# mv sendmail.cf /etc/mail
# mv /etc/sendmail.cf /etc/mail/sendmail.cf-dist
# ln -s /etc/mail/sendmail.cf /etc/sendmail.cf
# cp /etc/aliases /etc/mail/aliases
# rm -f /etc/aliases*
# ln -s /etc/mail/aliases /etc/aliases
the directory /etc/mail generally needs a bunch of files in it, many of which can be empty:
# ls /etc/mail
access            genericstable     sendmail.ct       virtusertable
access.db         genericstable.db  sendmail.cw       virtusertable.db
aliases           relay-domains     sendmail.mc
aliases.db        sendmail.cf       sendmail.st
#
all of the .db files are created with the 'makemap' command (makemap is distributed with sendmail, you may need to compile it.
# cd /etc/mail
# makemap btree access < access
# makemap btree genericstable < genericstable
# makemap btree virtusertable < virtusertable
# newaliases
MAKE SURE YOU ADD ALL THE DOMAINS FOR WHICH YOU RECIEVE MAIL INTO /etc/mail/sendmail.cw!!!!! This is the most common error related to sendmail installations. Add domains one per line in this file, for instance:
sample.org
sample.com
The access file is for anti-spam purposes, see the sendmail homepage at www.sendmail.org for details. The genericstable and virtusertable are usefull when hosting multiple domains.

The genericstable allows you to customize where incoming mail goes, for instance say sample.com is hosted on your mail server, you can customize where mail is delivered by created the following entries in your genericstable

info@sample.com		sampinfo
sales@sample.com	samplesales@dialup.isp.com
@sample.com		smpadmin
This sends info@sample.com to the sampinfo account, sales@sample.com to samplesales@dialup.isp.com and all other mail to the smpadmin account (ie: marketing@sample.com, or any other address). You need to re-run makemap as shown above any time any of the .db files are changed

Once your config file is complete, start up sendmail:

# /usr/lib/sendmail -bd -q1h
That may be '/usr/sbin/sendmail' on some systems. Also run 'newaliases' which will complain if there are any configuration errors in your config file.

Where to get it

the .m4 files come with sendmail which is distributed from ftp.sendmail.org in /pub/sendmail. There's a home page at www.sendmail.org.
m4 is availible from your nearest GNU repository or from ftp.gnu.ai.mit.edu in /pub/gnu

Last updated: Wed Sep 16 11:43:33 PDT 1998
This is part of Nik's website - email me with questions or comments at nikm@cyberflunk.com.

:wq