sendmail

sendmail is the program that most servers on the internet use to send and recieve email (those that don't use sendmail generally don't work very well). Sendmail is a complicated program that does alot of things and is highly configureable, thus generally being difficult to install. This page covers compiling sendmail - see this page for information on configuring your sendmail.cf.

Installing

To install sendmail you need to have libdb installed. Most modern operating systems included libdb in their distribution, but if they don't it's very easy to install. If you're running linux or *bsd you probably have libdb installed already.

To check:

floor:/home/users/nikm# ls -l /usr/lib/libdb* /usr/local/lib/libdb*
-rw-r--r--   1 root     root        85154 Jul 12  1997 /usr/lib/libdb.a
lrwxrwxrwx   1 root     root           15 Jul 16 09:28 /usr/lib/libdb.so -> libdb.so.1.85.4
lrwxrwxrwx   1 root     root           15 Jul 16 07:40 /usr/lib/libdb.so.1 -> libdb.so.1.85.4
-rwxr-xr-x   1 root     root        58552 Jul 12  1997 /usr/lib/libdb.so.1.85.4
lrwxrwxrwx   1 root     root            9 Jul 16 09:27 /usr/lib/libdbm.a -> libgdbm.a
lrwxrwxrwx   1 root     root           16 Jul 16 09:27 /usr/lib/libdbm.so -> libgdbm.so.1.7.3
as you can see, this machine has a shared libdb installed. If you have a static libdb installed, it's probably in /usr/local/lib as libdb.a - that's where I install it on SunOS and other non-linux unix's.

Installing libdb

prior to sendmail 8.9 version 1.X of libdb had to be used. Since 8.9, the newer libdb's can be used. lidb is distributed from www.sleepycat.com.
# tar xfz db-2.4.14.tar.gz
# rm db-2.4.14.tar.gz
# cd db-2.4.14/
# cd build.unix/
# ../dist/configure
[...]
# make
[...]
# make install
This should install libdb.a in /usr/local/lib and the header files in /usr/local/include.

Compiling sendmail

Next download sendmail from ftp.sendmail.org (in /pub/sendmail).
# tar xfz sendmail.8.9.1a.tar.gz 
# rm sendmail.8.9.1a.tar.gz 
# cd sendmail-8.9.1a
# cd src
# ./makesendmail
makesendmail may not always work successfully at first, and you may need to tune your Makefile. makesendmail creates a subdirectory called obj.<ostype>.<version>.<arch> ie: on this machine it's called 'obj.Linux.2.0.35.i686'. This machine failed to compile sendmail with the following errors:
# ./makesendmail CC=gcc
Configuration: os=Linux, rel=2.0.35, rbase=2, rroot=2.0, arch=i686, sfx=
Using M4=/usr/bin/m4
Creating obj.Linux.2.0.35.i686 using ../BuildTools/OS/Linux
Making dependencies in obj.Linux.2.0.35.i686
cc -M -I.  -DNEWDB   *.c >> Makefile
map.c:29: db.h: No such file or directory
udb.c:28: db.h: No such file or directory
make: *** [depend] Error 1
Making in obj.Linux.2.0.35.i686
gcc -O -I.  -DNEWDB     -c alias.c -o alias.o
gcc -O -I.  -DNEWDB     -c arpadate.c -o arpadate.o
gcc -O -I.  -DNEWDB     -c clock.c -o clock.o
gcc -O -I.  -DNEWDB     -c collect.c -o collect.o
gcc -O -I.  -DNEWDB     -c conf.c -o conf.o
gcc -O -I.  -DNEWDB     -c convtime.c -o convtime.o
gcc -O -I.  -DNEWDB     -c daemon.c -o daemon.o
gcc -O -I.  -DNEWDB     -c deliver.c -o deliver.o
gcc -O -I.  -DNEWDB     -c domain.c -o domain.o
gcc -O -I.  -DNEWDB     -c envelope.c -o envelope.o
gcc -O -I.  -DNEWDB     -c err.c -o err.o
gcc -O -I.  -DNEWDB     -c headers.c -o headers.o
gcc -O -I.  -DNEWDB     -c macro.c -o macro.o
gcc -O -I.  -DNEWDB     -c main.c -o main.o
gcc -O -I.  -DNEWDB     -c map.c -o map.o
map.c:29: db.h: No such file or directory
make: *** [map.o] Error 1
so I need to correct the Makefile INCDIRS path to update it to reflect the appropriate location of the db header files.
# cd obj.Linux.2.0.35.i686/
# vi Makefile
now I change a few things while I'm in here: I change the C compiler from
# C compiler
CC=     cc
to:
# C compiler
CC=     gcc
I make sure that MAPDEF is only '-DNEWDB' as any current installation shouldn't really be using anything else.
# define the database mechanisms available for map & alias lookups: 
#       -DNDBM -- use new DBM
#       -DNEWDB -- use new Berkeley DB
#       -DNIS -- include NIS support                                     
# The really old (V7) DBM library is no longer supported.
# See README for a description of how these flags interact.
#       
MAPDEF=  -DNEWDB
and I updated INCDIRS. In my debian installation of linux, the db header files that come with the shared libdb are in /usr/include/db - look in the following directories for db.h: /usr/include, /usr/include/db, /usr/local/include and /usr/local/include/db

I change:

# include directories
INCDIRS=
to:
# include directories
INCDIRS= -I/usr/include/db
if you're libdb is in /usr/local/lib you need to tell make. Change:
# library directories
LIBDIRS=
to:
# library directories
LIBDIRS= -L/usr/local/lib
and then check your LIBS line. Different operating systems need different libraries listed here. Generally, if it shows '-lnis' remove that bit, solaris will generally need a bunch of libraries.. normally I have to add -ldb on many systems except linux. My LIBS line is:
# libraries required on your system
#  delete -l44bsd if you are not running BIND 4.9.x
LIBS=    -ldb
but other OS's have different requirements. A solaris installation may need a LIBS line like:
# libraries required on your system
#  delete -l44bsd if you are not running BIND 4.9.x
LIBS=    -lsocket -lnsl -ldb
or maybe:
# libraries required on your system
#  delete -l44bsd if you are not running BIND 4.9.x
LIBS=    -lsocket -lnsl -ldb -lkstat
it generally depends on the version and installation.

OK, now you've corrected your makefile, run 'make CC=gcc' in the obj* directory:

# pwd
/home/source/sendmail-8.9.1a/src/obj.Linux.2.0.35.i686
# make clean
[...]
# make 
[...]
This should build the sendmail binary. Under SunOS srvrsmtp.c sometimes can fail to compile complaining about strtoul. If this happens to you, edit the makefile and add '-DBROKEN_ANSI_LIBRARY' to ENVDEF ie:
# environment definitions (e.g., -D_AIX3)
ENVDEF= -DBROKEN_ANSI_LIBRARY
then do a 'make clean' and a 'make' again.

Sometimes the compile of sendmail will complete, but will then fail trying to build the man pages becaus 'groff' is not installed. This is OK since we are only really looking for the sendmail binary.

Installing sendmail

Once you have a sendmail binary in your obj* directory, do a 'make install' from this directory. The install portion of some of the older distributed makefiles doesn't always work - there was once a reference to installing /dev/null as /etc/sendmail.st in a SunOS Makefile but I think that may have been fixed. If your make install fails because of this line, just delete that bit.

When successfully installed, you should have a /usr/lib/sendmail or /usr/sbin/sendmail binary on your system. Generally it's a good idea to delete all your old copies of sendmail once you're satisfied with the new install, especially under SunOS where there are alot of setuid sendmail binaries lying around in /usr/lib (ie: sendmail.mx) - I generally do a: "rm /usr/lib/sendmail*" prior to doing a make install on SunOS.

Check the date of the binary, and if it is freshly installed, move on to configuring sendmail.

Where to get it

sendmail is distributed from ftp.sendmail.org in /pub/sendmail. There's a home page at www.sendmail.org.
libdb is distributed from www.sleepycat.com.

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

:wq