Linux HOWTOs

About | Home | Search


HOWTO: sendmail-beta
Description: Mail transport agent. The most widely used, and the best IMHO.
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# sendmail 8.12.11.Beta0
# ======================
# Slackware 9.0's 'sendmail' package includes version 8.12.8 and includes
# 8.12.10 in patches.  9.1 includes 8.12.10

# See the regular sendmail howto for the full 8.12.11 version

# Prerequisites:
# make
# gcc
# binutils
# fileutils
# m4
# OpenSSL (optional; for STARTTLS)
# Cyrus SASL (optional; for SMTP AUTH)
# OpenLDAP (optional; for LDAPMAP)
# Berkeley DB

# If you're replacing a Slackware installed sendmail, backup whatever
# files you need to, then run "removepkg sendmail sendmail-cf" to remove it.

# If you don't have user and group 'smmsp', add them:
getent group | grep "^smmsp:" > /dev/null || groupadd -g 25 smmsp
id smmsp > /dev/null 2>&1 || useradd -g 25 -u 25 smmsp

# Remove various patches and other files that we used to use/need for older
# versions, but don't need any more:
rm -f ~/installed/smrsh-20020924.patch ~/installed/proto.m4.8.649.2.13 \
 ~/installed/proto.m4.8.649.2.14 /usr/include/mfapi.h /usr/include/mfdef.h \
 /usr/lib/libsm.a /usr/lib/libsmdb.a /usr/lib/libsmutil.a

cd
test -f installed/sendmail.8.12.11.Beta0.tar.gz &&
 mv installed/sendmail.8.12.11.Beta0.tar.gz .
test ! -f sendmail.8.12.11.Beta0.tar.gz &&
 wget ftp://ftp.sendmail.org/pub/sendmail/sendmail.8.12.11.Beta0.tar.gz

# Verify tarball w/ md5sum:
# (taken from my gpg verified tarball)
echo "41754f0729a3fb27837eca6d89022ca5" ; md5sum sendmail.8.12.11.Beta0.tar.gz

# Verify tarball w/ gpg:
( gpg --list-keys 396F0789 > /dev/null 2>&1 || gpg --recv-keys 396F0789 ) &&
 wget -nc ftp://ftp.sendmail.org/pub/sendmail/\
sendmail.8.12.11.Beta0.tar.gz.sig &&
 gpg --verify sendmail.8.12.11.Beta0.tar.gz.sig &&
 rm sendmail.8.12.11.Beta0.tar.gz.sig

# Back-up your existing sendmail configuration files.  If your configuration
# files come from the sendmail-cf Slackware package, in Slackware 9.0
# they'll be in /usr/share/sendmail.
#
# If you have a source-installed sendmail in /usr/local/src (where this howto
# puts it) with your sendmail.mc and submit.mc files in cf/cf/, you can run
# this blurb below to back them up for you.  It assumes that you only have
# one version of sendmail's source in /usr/local/src.
#
# NOTE: be careful - if you keep your sendmail.mc and submit.mc in the
# last version's cf/cf/ dir and something goes wrong with this blurb,
# the next blurb will wipe them out along with the source tree.
# Make sure your old config files really do make it into
# ~/backup/sendmail/$OLDVER before you move past this part.
cd /usr/local/src &&
OLDVER=`find -type d -maxdepth 1 -name "sendmail-*" 2> /dev/null | tail -1`
test -n "$OLDVER" && (
 OLDVER=`basename $OLDVER` &&
 mkdir -p ~/backup/sendmail/${OLDVER} &&
 test -f ${OLDVER}/devtools/Site/site.config.m4 &&
  cp -f ${OLDVER}/devtools/Site/site.config.m4 ~/backup/sendmail/${OLDVER}/
 test -f ${OLDVER}/cf/cf/sendmail.mc &&
  cp -f ${OLDVER}/cf/cf/sendmail.mc ~/backup/sendmail/${OLDVER}/
 test -f ${OLDVER}/cf/cf/submit.mc &&
  cp -f ${OLDVER}/cf/cf/submit.mc ~/backup/sendmail/${OLDVER}/
 find ~/backup/sendmail/$OLDVER -type f -exec chmod 600 {} \;
)
OLDVER=

cd /usr/local/src
find -type d -maxdepth 1 -name "sendmail-*" -exec rm -r {} \;
tar xzvf ~/sendmail.8.12.11.Beta0.tar.gz
cd sendmail-8.12.11.Beta0
chown -R root.root .

# Skip this section if you want to build a "normal" sendmail
#
# If you already have a site.config.m4 backed up for this version of
# sendmail, restore it and skip to the next section:
test -f ~/backup/sendmail/sendmail-8.12.11.Beta0/site.config.m4 &&
 cp ~/backup/sendmail/sendmail-8.12.11.Beta0/site.config.m4 devtools/Site/
#
# See devtools/README for more information
cd devtools/Site
#
# Add build settings to site.config.m4 to build sendmail with that
# particular feature.  If this is not your first run through with this
# version of sendmail, make sure you wipe the existing site.config.m4
#
# MILTER (mimedefang, amavis, etc.)
echo "APPENDDEF(\`conf_sendmail_ENVDEF', \`-DMILTER')" >> site.config.m4
#
# SASL2 (smtp authentication)
echo "APPENDDEF(\`conf_sendmail_ENVDEF', \`-DSASL=2')" >> site.config.m4
echo "APPENDDEF(\`conf_sendmail_LIBS', \`-lsasl2')" >> site.config.m4
#
# STARTTLS (smtp + tls/ssl)
echo "APPENDDEF(\`confINCDIRS', \`-I/usr/local/ssl/include')" >> site.config.m4
echo "APPENDDEF(\`confLIBDIRS', \`-L/usr/local/ssl/lib')" >> site.config.m4
echo "APPENDDEF(\`conf_sendmail_ENVDEF', \`-DSTARTTLS')" >> site.config.m4
echo "APPENDDEF(\`conf_sendmail_LIBS', \`-lssl -lcrypto')" >> site.config.m4
#
# LDAPMAP (ldap mail routing - ie. aliases, virtusertable, etc. in LDAP)
echo "APPENDDEF(\`confMAPDEF', \`-DLDAPMAP')" >> site.config.m4
echo "APPENDDEF(\`confLIBS', \`-lldap -llber')" >> site.config.m4
#
# Berkeley DB 4.0.x
echo "APPENDDEF(\`confINCDIRS', \`-I/usr/local/BerkeleyDB.4.0/include')" \
 >> site.config.m4
echo "APPENDDEF(\`confLIBDIRS', \`-L/usr/local/BerkeleyDB.4.0/lib')" \
 >> site.config.m4
#
# Berkeley DB 4.1.x
echo "APPENDDEF(\`confINCDIRS', \`-I/usr/local/BerkeleyDB.4.1/include')" \
 >> site.config.m4
echo "APPENDDEF(\`confLIBDIRS', \`-L/usr/local/BerkeleyDB.4.1/lib')" \
 >> site.config.m4
#
# Berkeley DB 4.2.x
echo "APPENDDEF(\`confINCDIRS', \`-I/usr/local/BerkeleyDB.4.2/include')" \
 >> site.config.m4
echo "APPENDDEF(\`confLIBDIRS', \`-L/usr/local/BerkeleyDB.4.2/lib')" \
 >> site.config.m4
#
cd ../..

# Don't use this on HP-UX or Solaris!; hence the 'force-install' below.
# If you use Cyrus, make that your local mailer (don't use mail.local).
# If building mail.local (to use instead of procmail):
( cd mail.local ; ./Build ; ./Build force-install )

# If building milter (this won't do anything if it's not configured to build):
grep '\-DMILTER' devtools/Site/site.config.m4 > /dev/null 2>&1 &&
 ( cd libmilter ; ./Build ; ./Build install )

# Build and install sendmail
./Build
./Build install

cd
mkdir -p -m 0700 installed
rm -f installed/sendmail.*.tar.*
mv sendmail.8.12.11.Beta0.tar.gz installed/


# Create directories, update permissions
mkdir -p /var/spool/clientmqueue /var/spool/mqueue
chmod go-w / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue
chown root / /etc /etc/mail /usr /var /var/spool /var/spool/mqueue
chown root.root /etc/mail/*.db
chown root.smmsp /etc/mail/aliases.db
chmod 640 /etc/mail/*.db /etc/mail/aliases /etc/mail/statistics
touch /etc/mail/sendmail.cf /etc/mail/submit.cf
chown root.wheel /etc/mail/sendmail.cf /etc/mail/submit.cf
chmod 444 /etc/mail/sendmail.cf /etc/mail/submit.cf
test -f /var/run/sendmail.pid && chmod 600 /var/run/sendmail.pid
chown smmsp.smmsp /var/spool/clientmqueue
chmod 770 /var/spool/clientmqueue
chown -R root.wheel /var/spool/mqueue
chmod -R 700 /var/spool/mqueue

# Restore backed up config files for this version if you already have them:
cd /usr/local/src/sendmail-8.12.11.Beta0/cf/cf
test -f ~/backup/sendmail/sendmail-8.12.11.Beta0/sendmail.mc &&
 cp -f ~/backup/sendmail/sendmail-8.12.11.Beta0/sendmail.mc .
test -f backup/sendmail/sendmail-8.12.11.Beta0/submit.mc &&
 cp -f backup/sendmail/sendmail-8.12.11.Beta0/submit.mc .


# SSL certs for sendmail
# ======================
# Make sure /usr/local/ssl/bin is in your PATH before you run this
#
cd /usr/local/ssl
test -f demoCA/cacert.pem && mv -f demoCA/cacert.pem demoCA/cacert.pem.old
test -f newcert.pem && mv -f newcert.pem newcert.pem.old
test -f newreq.pem && mv -f newreq.pem newreq.pem.old
misc/CA.pl -newca
misc/CA.pl -newreq-nodes
misc/CA.pl -sign
mkdir -p -m 0700 /etc/mail/certs
cp demoCA/cacert.pem /etc/mail/certs/CAcert.pem
cp newcert.pem /etc/mail/certs/cert.pem
cp newreq.pem /etc/mail/certs/key.pem
chmod 600 /etc/mail/certs/*
# Remove the req part from /etc/mail/certs/key.pem leaving just the key


# MSP Usage
# =========
# Run this from cron every so often (every 15 minutes?) to flush
# the client queue.  Do this if you don't want/need to have a sendmail
# daemon running like the next example.
/usr/sbin/sendmail -Ac -q

# Run as an msp daemon with submit.cf  The -L part will make it log
# 'sm-msp-queue' as the program name in syslog instead of 'sendmail'.
# -Ac means use submit.cf instead of sendmail.cf  The -q part tells it
# to flush the queue every 30 minutes.  This one will fork a process
# to run the queue.
/usr/sbin/sendmail -L sm-msp-queue -Ac -q30m

# Start a persistant queue runner (see -qp in the sendmail man page) using
# submit.cf, 'sm-msp-queue' program name for syslog, sleep time of 1 minute.
# This one will have one persistant queue runner process that sleeps for
# a minute in between runs.
/usr/sbin/sendmail -L sm-msp-queue -Ac -qp1m

# View the msp mail queue:
/usr/sbin/sendmail -bp -Ac


# MTA Usage
# =========
# Run from cron to flush the mta queue:
/usr/sbin/sendmail -q

# Run as an mta daemon with sendmail.cf  Use 'sm-mta' as the program
# name in syslog, flush the queue every 15 minutes.
/usr/sbin/sendmail -L sm-mta -bd -q15m

# View the mta mail queue(s):
# (they all do the same thing)
/usr/sbin/sendmail -bp -Am
/usr/sbin/sendmail -bp
/usr/bin/mailq


# I have the /etc/rc.d/rc.sendmail script from Slackware 9.0 here:
# http://englanders.cc/pub/linux/misc/notmine/rc.sendmail
#
# And if you want another one that'll handle starting/stopping/restarting
# sendmail, MIMEDefang, clamd, sophie, trophie, etc., grab this one:
cd /etc/rc.d
test -f rc.sendmail &&
 ( mv -f rc.sendmail rc.sendmail.old ; chmod 600 rc.sendmail.old )
wget http://englanders.cc/pub/linux/misc/rc.sendmail
chmod +x rc.sendmail

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>