Building, Installing, and Configuring sendmail 8.9.x Mini HOWTO by John E. Gotts v1.3, March 13, 1999 Introduction ------------ Once upon a time, getting sendmail to work with Linux was an arduous task. Many distributions did not even ship with sendmail and those that did very often shipped it improperly configured. The situation has improved somewhat, but it is still advantageous to install and configure sendmail for yourself: 1) Security holes are constantly being found and exploited in sendmail. (This is understandable, since sendmail is a large and complex program which runs as root.) You might want to apply a security patch or try out a bug-fix release before it becomes available with your distribution. 2) You might want to exploit masquerading or deferred delivery mode, neither of which may be enabled by your distribution. (These options are extremely useful for machines with intermittent connections to the Internet.) You can skip to the configuration section if all you need to do is reconfigure sendmail. 3) You might be interested in evaluating a new sendmail release just to try out new features. The purpose of this document is to explain in detail how to build, install, and configure sendmail 8.9.x under Linux. Obtaining sendmail ------------------ You can FTP sendmail 8.9.x from the following location: ftp://ftp.sendmail.org/pub/sendmail/ Unpacking sendmail ------------------ Unpacking sendmail 8.9.x is straightforward: tar zxvf sendmail.8.9.x.tar.gz Building sendmail ----------------- Change into the BuildTools/Site directory and create site.config.m4: define(`confCC', `gcc') define(`confOPTIMIZE', `-O3') define(`confLIBSEARCH', `db') define(`confMANOWN', `root') define(`confMANGRP', `0') define(`confMANMODE', `644') define(`confSBINGRP', `0') define(`confSBINMODE', `4711') define(`confUBINOWN', `root') define(`confUBINGRP', `0') define(`confUBINMODE', `755') You can change -O3 to whatever optimization flag(s) you normally use, but you should not need to modify the other settings. Now change into the src directory and execute: ./Build The build process should proceed without errors, placing the object files and the sendmail executable in a separate directory. Configuring sendmail -------------------- Henceforth I'm going to assume that you just use TCP/IP electronic mail. UUCP configuration is beyond the scope of this document. Change into the cf/cf directory and create a new file, generic-linux2.mc: VERSIONID(`@(#)generic-linux2.mc 8.10 (Local) 3/13/1999') OSTYPE(linux)dnl FEATURE(nouucp)dnl MAILER(local)dnl MAILER(smtp)dnl If you want to use masquerading, add the following line: MASQUERADE_AS()dnl This means that all the e-mail that gets sent from your machine (except e-mail from root) will appear to have originated from the hostname that you specify. (This option is useful for people with intermittent network connections, i.e. users of SLIP and PPP, and for people with machines that have dynamically assigned IP addresses via BOOTP or DHCP.) The following two lines may also be useful for people with intermittent network connections: FEATURE(masquerade_envelope)dnl FEATURE(nocanonify)dnl masquerade_envelope masquerades the "envelope" of outgoing messages and nocanonify turns off canonification of e-mail addresses. If you want to use procmail as your local mailer (highly recommended), add: define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl FEATURE(local_procmail)dnl after the other FEATURE macros. Transform "generic-linux2.mc" into a sendmail configuration file like so: ./Build generic-linux2.cf You should then edit generic-linux2.cf and remove or comment out the following line: Cwlocalhost Back up your old /etc/sendmail.cf file and install generic-linux2.cf: install -m 644 generic-linux2.cf /etc/sendmail.cf After you've installed your new sendmail.cf, kill the sendmail daemon, change back into the src directory, and execute: ./Build install This will install the sendmail binary, symbolic links, and man pages. If you haven't opted to use procmail, change into the main sendmail directory and type: uudecode contrib/mail.local.linux mv mail.local mail.local.old tar zxvf mail.local.linux.tar.Z cd mail.local gcc -O3 -o mail.local mail.local.c strip mail.local install -m 2711 -g mail mail.local /bin install -m 644 mail.local.8 /usr/man/man8 But beware of the following: http://linuxsavvy.com/resources/linux/sendmail-8.9.x-mail.local-alert Your /var/spool/mail directory needs to be mode 775, owned by user root and group mail. Your mail clients need to be SGID mail (mode 2711 and owned by user root and group mail). Now you should be ready to restart your sendmail daemon. Mine is started like this: /usr/sbin/sendmail -bd -q1h NOTE: Make sure your startup scripts start sendmail with its full pathname, e.g. as /usr/sbin/sendmail. If you have an intermittent connection, you might want to start sendmail in deferred mode: /usr/sbin/sendmail -bd -o DeliveryMode=d on boot and invoke sendmail as: /usr/sbin/sendmail -q to deliver all deferred e-mail when you first connect to the network and periodically while you are connected (perhaps as a cron job). Testing sendmail ---------------- At this point, you should test your new sendmail installation. Here's one way to do this: % telnet localhost smtp Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 ESMTP Sendmail 8.9.3/8.9.3; Sat, 13 Mar 1999 18:28:21 -0500 helo localhost 250 Hello jgotts@localhost [127.0.0.1], pleased to meet you mail from: jgotts@linuxsavvy.com 250 jgotts@linuxsavvy.com... Sender ok rcpt to: jgotts 250 jgotts... Recipient ok data 354 Enter mail, end with "." on a line by itself This is a test. . 250 CAA12172 Message accepted for delivery Also, be sure to test that your e-mail clients still work and try sending a test message to your machine from an outside source to verify that incoming e-mail still works. Concluding Remarks ------------------ As you have seen, getting sendmail up and running is not as difficult as you might have heard. Hopefully this document was instrumental in getting you started and will encourage you to explore some of the more interesting aspects of this complex piece of software. As always, if you have any questions or comments, please send me e-mail at: jgotts@linuxsavvy.com Have a nice day!