Notice: This material is excerpted from Running A Perfect Internet Site with Linux, ISBN: 0-7897-0514-1. The electronic version of this material has not been through the final proof reading stage that the book goes through before being published in printed form. Some errors may exist here that are corrected before the book is published. This material is provided "as is" without any warranty of any kind.

Copyright ©1996, Que Corporation. All rights reserved. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Que Corporation, 201 West 103rd Street, Indianapolis, IN 46290 or at support@mcp .com.

Chapter 6 - Installing E-mail Server Software

Now that you've got Linux installed and accounts created, you can move on to getting your servers set up. Start with the one that's often the most necessary and useful: your electronic mail server. After all, e-mail is the most used tool on the Internet other than, perhaps, Ping!

There are three e-mail servers you may want to install. One is the Sendmail server, which will handle your SMTP mail to and from the Internet. Simple Mail Transport Protocol (SMTP) is the standard method for transmitting electronic mail from one site to another.

The second is a Post Office Protocol (POP) mail server. A POP server holds mail for people just like a post office box. Users can connect to the POP server as they wish and it will transfer their mail to them. Some POP servers can also send mail out to the rest of the Internet.

Finally, there is a Unix to Unix Copy (UUCP) server. UUCP, in a way, is between SMTP and POP. It gets and sends out its files in batches at regular intervals, and doesn't require a permanent connection as long as it's connected during its file transfers. Many sites are more likely to have their users using UUCP from home to get and send their mail, than use it for their own mail transfer. This server is useful for more than e-mail, it also can transfer news (chapter 9, "Installing UseNet Server Software," has more about setting up this function).

In this chapter, you learn how to set up:

Setting Up Sendmail

The Sendmail server was conveniently installed during the Linux setup process that you went through in chapter 4, "Installing Linux from the CD-ROM." This includes a basic Sendmail configuration file (sendmail.cf). Although the basic configuration file was set up during the installation process, there is more work to be done to configure it for your particular needs.

If you have not installed Sendmail, log in as root and type setup. Add a package; the Sendmail items are on disk set N. To save a little time, choose the option that sets up your sendmail.cfg file.

Although there are entire books on the subject of Sendmail, I'm going to show you how to set up your Sendmail server for the basic tasks that you need to be able to perform. In the section, "Setting Up Sendmail for Local Mail Delivery," you'll learn how to configure your mail server to handle the following functions:

Don't get the Sendmail files confused with the smail files. Smail is a completely different mail server!

Smail is an older program that was written so people wouldn't have to deal with the complexity of Sendmail. However, because you can now start with a generic sendmail.cf file and simply modify it, Sendmail has become much easier to use (you used to have to do it all from scratch). So, smail is not so necessary anymore.

Additionally, smail is only really suited for small use. Sendmail is necessary for running a full Internet site.

Anything that you do in this chapter, you'll do from your root account.

Setting Up Sendmail for Local Mail Delivery

You're already equipped for basic local mail delivery if you chose to let the Linux installation program set up your sendmail.cfg file (see fig. 6.1). You'll need to take care of a few items, though, to make sure things run smoothly.

Fig. 6.1 Local mail delivery.

Setting Sendmail To Start as a Daemon

First, you need to make the Sendmail daemon launch at boot time. A daemon is a program that runs in the background and watches for the items it's supposed to handle, in this case, mail. If you don't have your Sendmail daemon running, it won't be sitting and waiting to process incoming and outgoing mail.

To make sure the Sendmail daemon is loaded, do the following:

  1. Go to the directory /etc/rc.d.
  2. Open the file rc.net.
  3. Look for the following lines of code toward the bottom of the file:
  1. If you find these lines, you can close the file. If you don't, then add them in the section where the other daemons are started. You can easily recognize them because each item that starts a daemon looks similar to the Sendmail code in step 3.

The code for the Sendmail daemon is not as complicated as it looks. It breaks down as follows:

  1. The first line looks to see if the file /usr/lib/sendmail exists.
  2. The second line changes to your mail queue directory and removes any lock files that might be left over if you had to reboot while your system was processing mail.
  3. The third line actually starts the Sendmail daemon. The switches that you use mean the following:
  1. -q1h tells your system to process the mail queue once an hour. If you want it processed more often, every 30 minutes for example, enter -q30m. The rest of this line simply tells your system to put the word sendmail on your screen (/dev/console).
  2. How often you have the mail queue processed depends on how much mail goes out of your site. If it's a lot, you may want to process the queue more often, because it will take up smaller chunks of your CPU time and bandwidth than doing it in large pieces. If your site sends out a lot of mail-especially if it has mailing lists-you may want to process the queue as often as every 15 minutes.
  3. The final line just ends the if/then statement.

Setting Aliases

Now, set a few aliases for Sendmail to make life a little more convenient and to make your system a little more in tune with the other sites on the Net.

To set the aliases, do the following:

  1. Open the file /etc/aliases.
  2. Add the aliases you want; it doesn't matter where you put them in the file. I recommend that you keep them together and add comment lines to remind yourself what the aliases are for. An example of what I might add at this stage is as follows:
  1. Save the aliases file.
  2. Type newaliases to activate the aliases you just added.

The following are some general alias ideas:

Fig. 6.2 Aliasing an address to multiple userids.

Setting Up Sendmail To Handle Internet Mail

Setting up your mail server to handle mail to and from the Internet is a little more complicated than processing local mail (see fig. 6.3). In this section, you'll learn to use the sendmail.cf file. Fortunately, you've got a sample config file already on your system that's preset to meet your TCP/IP and UUCP needs, so your work's been started for you!

Fig. 6.3 Sending mail out to the Internet.

Finding Your Way Through a sendmail.cf File

The following are a few tips to keep in mind when you're digging your way through a sendmail.cf file:

Fortunately, there's really little you have to change at first if you chose the appropriate default file during your Linux installation. As you add more services-especially such services as electronic mail to fax-you'll need to get a bit more technical with your sendmail.cf file.

Commands in a sendmail.cf File

It takes a little getting used to, but just remember that commands are only one character long in your sendmail.cf file, and the first letters on the line are the commands, as shown in table 6.1.Table 6.1 Commands Used in sendmail.cf

Command Use     Syntax
D       Defining macros D[macro][value]
C       Defining class macro    C[class][word1][...]
F       Defining class macros   F[class][filename]
        from files or pipes
H       Defining headers        H[?flag?][name]:[format]
M       Defining mailers        M[name],[field]=[value]
O       Defining options        O[option][value]
P       Defining delivery       P[name]=[value]
        priorities
R       Defining rewriting rules        R[lhs][rhs][comment]
S       Declaring new ruleset   S[number]
        starts
T       Declaring trusted users T[user1][user2][...]

The following are some examples and a more in-depth discussion of the two straightforward sendmail.cf commands:

The rest of the Sendmail commands have their own extra parameters, and there are entire books on how to use them properly. Instead of going into an exhaustive discussion about what each parameter can do, I will recommend the changes that you should make.

Recommended Changes to Your sendmail.cf File

All these changes are at the beginning of the sendmail.cf file, where the machine and site information is stored (the macro definition section). When multiple machines are mentioned-and there are different changes to make to different machines-I am referring to the individual sendmail.cf files on each machine. I recommend you make sure the following lines exist:

  1. DSyour.main_server.name
  2. This line defines your smart relay host, telling Sendmail to send anything it can't handle with its own rule sets. For example, I'm setting up a server on ABC company's network where there are the following computers: red, green, blue, and yellow. Their domain name is abc.com. Our main server is red, and the other three go through it to the Internet. On green, blue, and yellow, I would put in their sendmail.cf files the line:
  1. DRyour.main_server.name
  2. This line determines where mail to unqualified names goes, telling Sendmail where to send e-mail that's going to someone who doesn't exist. On the three machines that aren't ABC's main server, I would use the line:
  1. DHyour.main_server.name
  2. This determines where all local e-mail traffic goes. If you are using a centralized mail server, you'll want to use the same settings as in the DR section. If you're using a separate mail server, you'll use the name of that server on all the machines.
  3. DMyour.site_domain.name
  4. You use this line to have all of your site's e-mail masquerade as though it were coming from a particular common area. In all the sendmail.cf files on all the computers in ABC's network, I have:
  5. DMabc.com
  6. This means that if someone sends e-mail to user@domain, it won't be rejected because it's missing its host name. For example, people can write to me at either dee@abc.com or dee@green.abc.com and the message will get to me. If I hadn't set the DM value, the people sending me e-mail at dee@abc.com would have their mail bounced back.
  7. When you log into a specific computer on the network, if they've all mounted the same mail spool (mounting directories across computers is covered in chapter 5, "Setting Up Your Site for General Use"), it doesn't matter if something is just sent to user@domain.com or not. If all the machines are mounting the same mail directory, they're all going to see the same list of mail, even if it isn't directly sent to each of the machines.
  8. CEusername
  9. This tells Sendmail which userids shouldn't be masqueraded. For example, root isn't the same person at all of our machines. Therefore, if someone wrote to just root@ abc.com they may not be writing to the proper person. Instead, I will include the following:
  10. CEroot
  11. Now, root@abc.com will not be treated as a valid userid even though any other userid@abc.com would be just fine. To write to the admin of the machine green, for example, they would have to write to root@green.abc.com.
  12. If one person is in charge of all the machines on your site and is root at all of these machines, then do not include the CEroot in your sendmail.cf files.

Setting Up Sendmail to Handle UUCP Mail

If you're using UUCP as well, there really aren't any changes you have to make as long as you used the sendmail.cf that includes UUCP capability. However, only your main server (in ABC's case red) should have the UUCP version of this file. The other computers' sendmail.cf files should not have UUCP capability (see fig. 6.4).

Fig. 6.4 Sending out UUCP mail.

You may not want to send or get mail by UUCP, but you may have dial-in users sending and getting mail by UUCP. If this is so, you still need to have UUCP defined in your sendmail.cf file.

If you need to install UUCP on your site, you can find it on the n disk set.

Now, if you don't intend to offer POP mail, you're finished setting up your mail server! Move ahead to the next chapter. If you do intend to offer POP mail, read the next section.

Setting Up POP Mail

To offer POP mail, you need to set up your POP mail server (see fig. 6.5). However, this is such a simple task, you won't even realize you've done any more work! Simply do the following:

Fig. 6.5 Getting POP mail.

  1. Log into root on your main server.
  2. Edit the file /etc/inetd.conf.
  3. Find the section of the file that allows and disallows various services.
  4. Add the following line (or delete the # sign in front of it if it already exists and is commented out):
pop3  stream  tcp  nowait  root  /usr/sbin/tcpd  /usr/sbin/in.pop3d

A line is commented out in these files if it begins with a number sign (#).

  1. If there's a similar line with pop2 in front of it, make sure there's a # sign in front of it to comment it out.
  2. Go to the other machines on your network and comment out anything referring to pop2 or pop3 by putting a # at the beginning of each of the lines. You only want the main server to handle POP connections.

POP2 is simply an older version of the POP server than POP3. When people refer to POP servers in general, they're referring to POP3. Some sites simply haven't upgraded to it yet.

If you want to allow people to use the Eudora e-mail client from a Windows or Macintosh machine to access your POP server, you need to get the server QPOPPER. It's available via FTP at sunsite.unc.edu/pub/Linux/system/mail.

Running Mailing Lists

One thing many Internet sites run is mailing lists. With mailing lists, you can have a centralized distribution point to send a piece of mail to a small or large number of people. You can have them for all of your users, for people interested in a particular hobby or discussion topic, or really anything else you might want a number of people to be able to talk about together.

In a way, a mailing list is like a members-only newsgroup. Everyone sees the posts that go to the list, but only if they're subscribed to it through the list software.

You can find majordomo on the FTP site ftp.greatcircle.com, in the directory /pub/majordomo. The first file you should look at is majordomo-1.93.README (the version number may be different when you go to download the file). It walks you through the installation process. The file itself is majordomo-1.93.tar.Z. You also may want to take a look through the other text files in this directory, such as the CERT file and the SECURITY file.

You may want to wait until you've installed some of the servers in this book before installing majordomo if you are new to compiling programs.

Some tips on running mailing lists:

Verifying that Your E-mail Works

Once you get a server installed, it's time to test it. With Sendmail, this is simple! Just send two pieces of mail. The first you should send to yourself. The second is mail to someone on another site on the Internet. Then, get the person to write you back (or write to an autoresponder that will write you back immediately).

If the mail you sent to yourself doesn't come back, check root's mail (or postmaster if you gave it a different account). An error message was likely sent there telling you where things might be misconfigured. If there's no mail in root, type mailq as root. If the mail you sent was stuck in the queue, then it will be listed along with its status. You can then force it to process (flush) the queue by typing sendmail -q.

If the mail you sent to yourself comes back, but the mail you sent out to the Internet doesn't arrive there, once again first check root's (or postmaster's) mail for any error messages. Also, check the mail queue again. If it's not in the queue, you can look in your system's logs for sendmail statements. If there's not a listing for that piece of mail stating Accepted for delivery, your uplink server (say, your provider's mail server) hasn't accepted the mail. If it wasn't accepted, there will be an error message-if you keep getting deferred as an error you may need to talk to your provider and see if it's having problems with its mail system.

If the first two tests worked, but the incoming mail doesn't arrive, first check root/postmaster's mail to see if there's an error message. Also, your logs will show a connection from the mail server it was coming from, but you won't see any messages about errors with the transfer. Other than that, you'll need to find out from the sender of the note if the mail bounced back, and what kind of error it bounced back with.

QUE Home Page

For technical support for our books and software contact support@mcp.com

Copyright ©1996, Que Corporation