Tim's Web Site 2.0

About Me

Miscellaneous

Geek Stuff

Skydiving


My Amazon.com Wish List

Geek Stuff : Tutorials : Archive : Sendmail How-To

Sendmail Configuration on Slackware Linux

Getting email services set up on your Slackware server is not that hard. There's just a few configuration files to tweak, and maybe create if they don't yet exist. In this tutorial you'll learn how to get basic email services working on your Slackware server, learn how to configure the server to limit an email message's size, and even how to use some things like the RBL (Real-time Blackhole List, for SPAM blocking) as well as how to block domains, email addresses, IPs and IP ranges/blocks to keep the spammer scum at bay.

Note: This page hasn't been updated since the middle of 2002, and it won't be updated again. It may still be somewhat useful though, but pay attention to the file names and things like the location of "m4" on your system.. I no longer respond to questions on this tutorial, so please don't send any. :)

Main Configuration File

The first file you will need to create is the .mc file, kept in the source area. This file basically lays out the basic stuff, and can also contain more advanced stuff for checking things like the Subject line before processing email. Anyway, get into the following directory with this command:

cd /usr/src/sendmail/cf

Now create a file called "sendmail.mc", you can actually call it anything you want (mine is called "tim.mc"), but "sendmail.mc" will be the name we use through the rest of this tutorial. You can create the file with the editor you like best, such as pico (which we will use for the rest of the tutorial), like this:

pico -w sendmail.mc

You should have a nice, and empty, new configuration file open. Type the following stuff into it, without the lines in red. The lines in red explain what the lines are for in some cases:

# m4 m4/cf.m4 sendmail.mc > /etc/mail/sendmail.cf
#
# This shows the version of Sendmail you are running now
# (This is the line from my Slackware 8.0 version)
VERSIONID(`8.11.14')
# Slackware is a Linux distro, so that's what we give next
OSTYPE(linux)dnl
DOMAIN(generic)dnl
# Just says to use the /etc/mail/sendmail.cf file we make from this
FEATURE(use_cw_file)dnl
FEATURE(always_add_domain)dnl
# Used for virtual domains, if you don't run more than one domain this is optional
FEATURE(virtusertable, `hash /etc/mail/virtusertable')dnl
# Used for relay, spam blocking and other info
FEATURE(access_db, `hash /etc/mail/access')dnl
# If you want to use the RBL for spam blocking, recommended
FEATURE(rbl)dnl
FEATURE(local_procmail)dnl
define(`LOCAL_MAILER_PATH', `/usr/bin/procmail')
# Define how many bytes large an email can be, optional
# (The following limits an email message to around 10 MB)
define(`confMAX_MESSAGE_SIZE', `10000000')
MAILER(local)dnl
MAILER(smtp)dnl
MAILER(procmail)dnl

The first line in this file is commented out. It just contains the command you need to use whenever you make changes to the file and want to create a new /etc/mail/sendmail.cf file. This just keeps it nice and handy to cut and paste from.

Some of the lines above are preceded by a red comment line explaining what they do. Some are optional. If you're in doubt you can paste them all in. The lines in red I have commented out, so if you paste the whole block into your /usr/src/sendmail/cf/sendmail.cf file they will not interfere with the configuration file.

Note: The # (pound sign) is used to denote a comment line in most Linux configuration files.

Support Files Needed

You will now create, if they are not already created, the support files needed in the /etc/mail directory on your server. Get into the directory with the following command:

cd /etc/mail

access File

Open or create the /etc/mail/access file with this command:

pico -w access

If the file does not already exist this will create it. Past the following information into the new file:

# /usr/sbin/makemap hash /etc/mail/access.db < /etc/mail/access
#
localhost                 RELAY
#
yourdomain.com            RELAY
anyotherdomains.com       RELAY

Basically, the command you will use to create the db file for this is in the commented out line up top, and it is there only as a convenience so that you can cut and paste it into the command line if you ever need to alter this file and hash it into a db again.

The next 3 lines are for any domains you want to be able to "relay" through your mail server. "localhost" is for the server itself, and the next lines could be for your domain (if you have one), any domains hosted on your machine, etc.. If a domain is not listed it will not be able to send email through your server. Any domains listed there should also be listed in the next section, where we cover the /etc/mail/sendmail.cw file..

sendmail.cw File

Open, or create, the /etc/mail/sendmail.cw file with this command:

pico -w sendmail.cw

Enter into this file 'localhost' (for the server) and any domains that are running on your server, like we mentioned before, like this:

localhost
yourdomain.com
anyotherdomains.com

Like the RELAY domains mentioned just before, any domains not listed here (as well as in the RELAY statements in the last file) will not be able to send email through your server. This is a good thing, since miserable spammers won't be able to pipe their crap through your server.

local-host-names File

This file, /etc/mail/local-host-names, file is identical to the previous /etc/mail/sendmail.cw file. Copy whatever domains you typed into that file into this one like this:

localhost
yourdomain.com
anyotherdomains.com

I need to check it out more, but I vaguely remember that when I tried to do without this file after upgrading to Slackware 8.0, with a newer Sendmail, that I needed it. Can't hurt to have anyway. When you modify the /etc/mail/sendmail.cw file just remember to also modify the /etc/mail/local-host-names file too.

aliases File

The aliases file is handy for pointing nonexistent accounts to usernames on the server. I usually point the following accounts to my personal username, so I get all their email:

root:             tim
webmaster:        tim
postmaster:       tim
hostmaster:       tim
postmaster:       tim
abuse:            tim

The aliases file already exists on your server (if you have Sendmail installed), and you don't need to modify it unless you want to make adjustments or receive 'root' email (or other stuff) at your personal address.

virtusertable File

If you run more than one domain on your server, or plan to, you will probably want to also run virtual email for those domain. If you do, create and open the virtusertable like this:

pico -w virtusertable

Note: If you specified the line "FEATURE(virtusertable, `hash /etc/mail/virtusertable')dnl" in your /usr/src/sendmail/cf/sendmail.mc file above you will need this file, even if it is empty.

If you use this file, enter any domain's email accounts (including your main domain) into the file like this:

# /usr/sbin/makemap hash virtusertable.db < virtusertable
#
you@yourdomain.com          tim
someone@yourdomain.com      tim
another@yourdomain.com      tim
@yourdomain.com             tim

Finishing Up!

We're almost there now.. We just need to create the /etc/mail/sendmail.cf from the /usr/src/sendmail/cf/sendmail.mc file using m4, hash a couple of files we made or modified in /etc/mail, and restart sendmail on the server. It's all just a matter of a few simple commands and we're done.

First backup whatever /etc/mail/sendmail.cf file is already on your system with this command:

cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf.original

Change directories back to the source directory with this command:

cd /usr/src/sendmail/cf

Now you will make the new /etc/mail/sendmail.cf file from the /usr/src/sendmail/cf/sendmail.mc file we made using the following command.

m4 m4/cf.m4 sendmail.mc > /etc/mail/sendmail.cf

You'll need to get back into the /etc/mail directory now:

cd /etc/mail

Next we will create the "aliases" database from the /etc/mail/aliases file like this:

newaliases

Then we will create the "access" database from the /etc/mail/access file. We'll be using the command we put in the comments at the top of that file, any time you make a change to the file in the future be sure to run that command again.

/usr/sbin/makemap hash /etc/mail/access.db < /etc/mail/access

Next we will create the "virtusertable" database from the /etc/mail/virtusertable file. Wether or not you run virtual domains on your server, run this next command anyway since we listed the file in your /usr/src/sendmail/cf/sendmail.mc file. If you only have one domain on the server it can be empty, but we'll need it hashed anyway. We'll be running the command we put at the top of the /etc/mail/virtusertable file in the comments. Any time you make a change to the file in the future be sure to run this command again:

/usr/sbin/makemap hash /etc/mail/virtusertable.db < /etc/mail/virtusertable

Restarting Sendmail

Sendmail will most likely be running automatically since it is started when the server boots and runs the /etc/rc.d/rc.M script. Now that we've made all of these changes we need to restart it so the changes take effect.

First find the PID (process ID) using this command while still logged on as the 'root' user:

ps -x

You'll then see the processes that are running now. Look for the Sendmail process, it will look something like this, and the process ID is the number at the far left:

5150 ?        S      0:00 sendmail: accepting connections

Restart the Sendmail PID (in this example it's "5150", yours will probably be a different number) with the following command:

kill -HUP 5150

Sendmail should now be running correctly on your machine, and ready for virtual domain service too should you ever need it. If you have any questions feel free to send me a message using the link below or in the left-hand nav. =)

©1995 - 2008 Tim Patterson, All Rights Reserved (Unless otherwise noted)