Henry's NotesHomeHomeSlackwareCamerasGadgets Installation Laptops Links Palm Printing Sound System Administration X Window System ContactEmail MeSearchAdvanced search |
Sendmail Installation and Configuration[Henry's Notes] -> [Slackware] -> [Email] I have trouble with the default settings for sendmail that are supplied with most distributions. Their assumptions don't seem to fit my needs at all. To satisfy those needs, I don't install sendmail with the distribution but install it from source, and I have three sendmail configuration files. I have a home network. Each of the desktop boxes passes the email up to my outgoing mail server. I also have an inbound mail server. So I have three sendmail configuration files - one for the desktops, one for the outgoing mail server and one for the incoming mail server. Where to get informationI got most of my knowledge to help me set my email system up from three sources.
Preliminary setupRemoving old sendmailsIf you already have sendmail installed, then get rid of it completely. I use Slackware so I use removepkg. I check for the executables, and directories like /usr/share/sendmail and /etc/mail and then I delete the lot. I make sure all trace of previous sendmails are gone. Start with a clean slate. Setup sendmail user and groupBefore doing anything else, check that the mail user and group are set up. Look in /etc/passwd for user smmsp with uid 25. Then check in /etc/group for group smmsp with gid 25. If they are there, good. If not, add them with:
Setup sendmail config directoryIf you don't have /etc/mail, then create it. Make sure that /etc and /etc/mail have correct permissions. Both should allow only the user (owner) to write to it. If this is not set correctly, then the aliases cannot be correctly created.
Setup spool directoriesWe need two spool directories - /var/spool/clientmqueue and /var/spool/mqueue. If they aren't there, create them. Then make sure they have the correct owner and permissions.
Compile and install sendmailDownload the latest version of sendmail from sendmail.org. Get the most recent stable on with the maximum security patches in it. Get source. Currently I am using sendmail 8.12.10. This shows how to get recent versions of sendmail running. To do this, you'll need to have m4 available. Make sure it's on your systems. If it isn't installed, get a copy and install it. Try Freshmeat. Or check your distribution disk and install from there. Most Linux will have it, but I've installed sendmail on Solaris and had to install m4 first. Compile sendmail
Install the sendmail executables and other files
Configure sendmail
Setup start/stop scriptsMake sure you have a startup script in /etc/rc.d (assuming Slackware). If you're not using Slackware, find the appropriate place. If you don't have a startup script for sendmail, set up something like this one, which comes from Slackware. Set permissions so it will execute. We need to start two instances of sendmail, one as an MTA to handle outbound mail, and one to handle the cleanup of the error queue (clientmqueue) rc.sendmail
#!/bin/sh
# Start/stop/restart sendmail.
# Start sendmail:
sendmail_start() {
if [ -x /usr/sbin/sendmail ]; then
echo "Starting sendmail MTA daemon: /usr/sbin/sendmail -L sm-mta -bd -q25m"
/usr/sbin/sendmail -L sm-mta -bd -q25m
echo "Starting sendmail MSP queue runner: /usr/sbin/sendmail -L sm-msp-queue -Ac -q25m"
/usr/sbin/sendmail -L sm-msp-queue -Ac -q25m
fi
}
# Stop sendmail:
sendmail_stop() {
killall sendmail
}
# Restart sendmail:
sendmail_restart() {
sendmail_stop
sleep 1
sendmail_start
}
case "$1" in
'start')
sendmail_start
;;
'stop')
sendmail_stop
;;
'restart')
sendmail_restart
;;
*)
echo "usage $0 start|stop|restart"
esac
Start sendmailOnce the startup script is in place, you can start sendmail with "/etc/rc.d/rc.sendmail start". Use ps to check that it started. Then view /var/log/maillog and check that it started okay and there are no errors. Test sendmail
Configuration filesmc file for desktopsThis mc file is for the desktops. It passes the mail up to a specific server. No other files need to be configured in /etc/mail. include(`../m4/cf.m4') VERSIONID(`sendmail for desktops')dnl OSTYPE(linux)dnl FEATURE(always_add_domain)dnl FEATURE(`masquerade_envelope')dnl MASQUERADE_AS(`hatty.com')dnl define(`SMART_HOST',`outbound.internal')dnl undefine(`USE_CW_FILE')dnl MAILER(local)dnl MAILER(smtp)dnl mc file for outgoing mail serverThis mc file is for the outgoing email server. This will accept email from the internal network desktops, and relay it to the final destinations. Relaying is on, but only for the internal network and this is controlled by the access file. include(`../m4/cf.m4') VERSIONID(`sendmail for outbound email server')dnl OSTYPE(linux)dnl FEATURE(`nouucp',`reject')dnl FEATURE(`access_db')dnl FEATURE(`blacklist_recipients')dnl define(`confSMTP_LOGIN_MSG', `outgoing mail server: passing on the mail')dnl MAILER(local)dnl MAILER(smtp)dnl For this to work, you also need to set up the /etc/mail/access file like this: 192.168.1 RELAY where the IP address specified is enough to identify only the network you want to relay email for. My home network is all 192.168.1.*, and 192.168.1 is enough to allow all email from all my local boxes to be relayed. So create /etc/mail/access and then "makemap hash access < access" to create the access.db database. mc file for incoming mail serverThis mc file is for the incoming email server. This will accept email from outside my network and save it for my users who pick it up using POP. This is the basic configuration with some extra blocking controls to control spam and with virtual domains. include(`../m4/cf.m4') VERSIONID(`sendmail for inbound email server')dnl OSTYPE(linux)dnl VIRTUSER_DOMAIN(hatty.com)dnl VIRTUSER_DOMAIN(annie.com)dnl FEATURE(`virtusertable', `hash /etc/mail/virtusertable')dnl FEATURE(`access_db')dnl FEATURE(`blacklist_recipients')dnl FEATURE(`nouucp',`reject')dnl define(`confSMTP_LOGIN_MSG', `generic mail server: accepting most mail')dnl MAILER(local)dnl MAILER(smtp)dnl The virtual domains are accepted by specifying them with VIRTUSER_DOMAIN. The virtusertable specifies what user gets the mail for the domains. This is my /etc/mail/virtusertable which directs all mail for the domains to those users. I have a login for each of those users. The file is turned into a database with "makemap hash virtusertable < virtusertable". @hatty.com hatty @annie.com annie Spam controls are provided by the access table. I can block specific To addresses, and specific From addresses, and specify the rejection message. This is turned into a database with "makemap hash access < access". To:hatty@hatty.com ERROR:550 Unsolicited junk mail is not accepted To:h5@hatty.com ERROR:550 Unsolicited junk mail is not accepted To:hussy@annie.com ERROR:550 No one here by that name From:lovelorn@iguana.net ERROR:550 Looking for love in all the wrong places Combining the serversRight now I keep the incoming and outgoing mail servers separate. That was because I set the system up when I hadn't learnt how to relay only from my internal network. Now that I know how to control that, I am considering using one server for both incoming and outgoing. The easiest configuration would use the same mc file for the incoming mail server, but add the line 192.168.1 RELAY to the access table. That should do it. 5 December 2003 |