Setting Up a Mail Server

For many of us, e-mail has become an essential part of life. When you send an e-mail, it is a mail server that is responsible for dispatching that mail to its intended destination; and at the other end, another mail server receives that message and passes it on to the appropriate mailbox.

A mail server can be configured to handle small home network e- mails or large, complex networks with hundreds of users. Many home users tend to use the mail server provided by their ISP. Many medium-to-large organizations host their own mail servers.

It s unlikely that you ll need to set up your own mail server, but in some situations there are good reasons for doing so:

  • Your mail server will be on the same network as your client machine, so connection between your client machine and mail server will be much faster.

  • If you have a dialup connection (rather than a dedicated Internet connection), having your own mail server allows you to work on your e-mail without ever having to connect manually to the Internet. You can configure your e-mail server to send and receive mail in batches, by connecting to the Internet at specified times.

  • You can customize a mail server s security and monitoring rules, so that it alerts you if it receives a message that contains certain blocked words or if it detects unusual activity.

Hosting your own mail server comes with its burdens, too. There s the increased cost of support and maintenance, and the additional chance of being compromised (you re protected from this if you use an ISP s mail server). It s also more important to ensure that you keep your antivirus software up to date, and that it scans each e-mail. And there is a risk that your mail server will become an open relay SMTP server (another user uses your mail server as a gateway for sending mail).

So, there s much to consider, and debate of these issues is outside the scope of this book. However, if you do decide to host your own mail server, you won t be surprised to learn that the Fedora 2 operating system comes with a default mail server. It s called Sendmail.

What Is a Mail Server?

A mail server is a collection of applications that provide the functionality to manage the tasks of sending and receiving e-mail, and delivering e-mail to users mailboxes. A mail server uses a number of different protocols to transfer e-mail from one system to other. Here s a brief description of these protocols:

  • The Internet Message Access Protocol (IMAP) is a protocol used by an e-mail client application to access the remote e-mail mailbox. The main advantage of IMAP is that users can manage the e-mail messages on remote mailboxes instead of downloading the messages onto their local machine. For more information on IMAP, take a look at .

  • E-mail clients use the Post Office Protocol (POP) to download e-mail messages from a remote server and save them on their local machine. For more information on POP, refer to RFC 1939 at .

  • The Simple Mail Transfer Protocol (SMTP) is used to send e-mails (this is in contrast with IMAP and POP, which are used to receive e-mails). Each e-mail message is transferred between remote e-mail servers using SMTP. Fedora 2 uses Sendmail as its default SMTP software.

E-mail Application Types

E-mail applications fall into the following three classes:

  • Mail User Agents (MUAs): An MUA is an e-mail client, a program that is used to retrieve and manage e-mail messages via POP or IMAP protocols. Examples of MUAs on Linux systems include Pine, Mutt, Ximian s Evolution, and Mozilla Mail. Microsoft s Outlook is also an MUA.

  • Mail Transfer Agents (MTAs): An MTA transfers e-mail messages between different machines using SMTP. During the course of its journey from source to destination, an e-mail message may transfer between several MTAs, hosted on different platforms. On Linux systems, Sendmail , Postfix , Exim , and Qmail are four different MTA applications. Fedora Core 2 uses Sendmail as its default MTA.

  • Mail Delivery Agents (MDAs): An MDA is used to deliver e-mail messages to users mailboxes. An MTA delivers messages to an MDA, which is then responsible for delivering it to the specified mailbox. Some MTAs (such as Sendmail ) can also act as MDAs. On Linux systems, MDAs include Sendmail , Procmail , and /bin/mail . MDAs are sometimes also known as LDAs (local delivery agents) .

Why Sendmail?

This section looks at how to use and configure the Sendmail mail server. Sendmail is a widely used mail server, which (as stated) can act both as MTA and MDA, and is capable of serving the needs of home users as well as larger networks. It can be used to send e-mail via the Internet as well as locally (and hence can be used as a local intranet mail server), and the latest version provides many security features. Sendmail also comes with good documentation.

Installing Sendmail

As you d expect, installing Sendmail is straightforward when you do it through the RPM GUI Tool. Once you ve started the tool (for example, by selecting Main Menu>System Settings>Add/Remove Applications), you need to select the Mail Server package group (which you ll find under the Servers category). If you click the Details button, you ll see the package details (see Figure 9-18).

The sendmail package is selected by default as a Required Packages. Under the Optional Packages, you should also select the dovecot (an imap server) and sendmail-cf packages. The sendmail package will install the Sendmail MTA (the SMTP server), while the dovecot package installs the POP and IMAP services, and sendmail-cf provides the facilities for reconfiguring Sendmail. You can deselect all other packages. Click Install Packages to start the installation. As usual, you ll need the Fedora 2 distribution CDs handy to complete the installation.

click to expand
Figure 9-18

Configuring Sendmail

Sendmail is very flexible and provides a lot of options for handling e-mail. While this abundance of features brings a lot of advantages and flexibility, it also brings complexity. Some aspects of Sendmail s configuration are difficult to understand, and even experienced system administrators make mistakes. We will go through a simple configuration that should get Sendmail up and running and able to send e-mails. We assume you have already configured your Linux machine to connect to the Internet, as described in Chapter 3.

The default installation of Sendmail places the sendmail executable in the /usr/sbin (that is, /usr/sbin/sendmail ). It also creates a symbolic link, /usr/lib/sendmail , which points to /usr/sbin/sendmail .

Sendmail s configuration files are contained within the /etc/mail directory. There are five configuration files of particular interest, as shown in the following table.

Configuration File


This lengthy and complex file is the default main file used by Sendmail. Although you can read this document, you re not supposed to edit it; rather, you edit the source file found in the same directory and then compile using the m4 utility (see the section Configuring Sendmail ).


This file specifies which systems can use Sendmail for relaying e-mail. It allows you to restrict the access to the mail server by individual domains.

local-host- names

This file specifies all aliases for your machine.


This file specifies domain name mappings.


This file allows a domain-specific form of aliasing. It allows multiple virtual domains to be hosted on one machine.

If you look in the /etc/mail directory, you ll see that some of these files are stored in two formats:

  • The access , domaintable , and virtusertable files are text files; they contain the configuration data that you specify to control how Sendmail works for you, and you can configure these files using a text editor such as gedit .

  • The access.db , domaintable.db , and virtusertable.db files are database files. These contain the same data, in a database format that the Sendmail application can use.

Whenever you adjust the configuration contained in the text files, you must subsequently compile them into database format so that Sendmail can use the new configuration.

Here s a brief example. If you wanted to allow all the systems in domain to use your e-mail server for relaying e-mail, you would add the following line in the access file:

 # by default we allow relaying from localhost... neptune.home         RELAY localhost            RELAY            RELAY        RELAY   

Then, you must convert the access text files to generate the access.db database file. To do this, use the makemap command:

   # makemap hash /etc/mail/access.db < /etc/mail/access   

This creates the access.db file (which is not human readable and can be used only by the Sendmail application).

Sendmail offers many configuration options to allow you to control almost every aspect of its behavior. We can t possibly cover them all here, but there are good resources on the Internet that will help you to set up your Sendmail installation the way you want it. A good place to start is .

A Simple Example Using Sendmail

To prove that Sendmail works, we ll demonstrate a little configuration of the Sendmail mail server. Then we ll see it in action, showing how it can act as an MTA ”collecting incoming e-mails and filtering theminto different mailboxes (according to the identity of the mail message s intended recipient).

We ll need to check the configuration of Sendmail, and then make sure all the necessary services are open. Then, to demonstrate, we ll masquerade as two different users, sending e-mails to each other across the system; and we ll see Sendmail in action, making sure that the messages get forwarded to the correct users mailboxes.

Configuring Sendmail

By default, Sendmail listens for incoming mails only on the loopback IP address, ”and this allows SMTP connections between the Sendmail server and the local machine only. This is sufficient for this example because it involves only senders and recipients whose accounts are on the local machine.

However, you would need to change the following part of the configuration file if you wanted to open up your Sendmail server to listen for incoming mails on other addresses:

 dnl # The following causes sendmail to only listen on the IPv4 loopback address dnl # and not on any other network devices. Remove the loopback  dnl # address restriction to accept email from the internet or intranet.  dnl #   DAEMON_OPTIONS('Port=smtp,Addr=, Name=MTA')dnl   

Here, the Port parameter specifies the port on which the Sendmail server, acting as MTA, is to listen for messages (the default is smtp , which is port 25). If you want to make Sendmail listen for messages coming in from the Internet or across an intranet, you remove the Addr restriction:

   DAEMON_OPTIONS('Port=smtp, Name=MTA')dnl   

Alternatively, you can specify a specific IP address on which Sendmail should listen. For example:

   DAEMON_OPTIONS('Port=smtp,Addr=, Name=MTA')dnl   

If you make changes to , you must then compile them into the file that Sendmail uses. To do this, you employ the m4 utility, like this:

   # m4 /etc/mail/ > /etc/mail/   

If you re stepping through this example for yourself, you can leave the DAEMON_OPTIONS directive as the default, so that Sendmail is listening only at .

Starting the SendMail Service

You shouldn t need to start the Sendmail service because it is configured to start up automatically on system startup. You can check the service s status in much the same way as the other services we ve mentioned in this chapter, via the Service Configuration GUI (Main Menu>System Settings>Server Settings>Services), where it is listed under the name sendmail (see Figure 9-19).

You can also start and stop the service manually at the command line by using the service command in the usual way, this time to control the /etc/init.d/sendmail script. For example:

   # service sendmail   Usage: /etc/init.d/sendmail {startstoprestartcondrestartstatus}   # service sendmail restart   Shutting down sendmail:                                        [  OK  ] Shutting down sm-client:                                       [  OK  ] Starting sendmail:                                             [  OK  ] Starting sm-client:                                            [  OK  ] 
click to expand
Figure 9-19

Testing the Configuration

If you change the Sendmail configuration, you can test the Sendmail connection by attempting to connect from a Windows machine on the same network. To do this, you can use the telnet command at the command prompt:

   > telnet 25   220 linuxbox ESMTP 8.12.11/8.12.11; Fri, 21 May 2004 00:04:45 +0100 

A response like the one shown here proves that Sendmail is listening on IP address , port 25. In this response, linuxbox refers to the hostname of the server on which Sendmail is running. Sendmail automatically detects the hostname of the machine (this could be an FQDN or the machine s IP address). To disconnect from this port, type quit .

You should also look for the messages in Sendmail log file /var/log/maillog to troubleshoot any problem. When you start the sendmail daemon, the log file displays the following messages:

   May 21 13:14:21 test sendmail[4040]: starting daemon (8.12.11): SMTP+queueing@01:00:00     May 21 13:14:21 test sm-msp-queue[4049]: starting daemon (8.12.11): queueing@01:00:00   

Sendmail also logs many other messages, such as messages sent and other error messages in the /var/log/maillog log file.

Setting Up Some E-mail Clients

To demonstrate this in action; we ll need two or three different user accounts. You could create some fictional user accounts using the User Manager Tool (Main Menu>System Settings>Users & Groups) or the useradd and passwd command line utilities (both of which you met in Chapter 7). Here s a reminder of the useradd and passwd utilities in action, creating and activating an account for one of the authors of this book:

   # useradd -c 'Mark Mamone' -s /bin/bash markm     # passwd markm   ... 

This example uses accounts markm and kapils; you can use different accounts if you like.

They also need to be configured with e-mail accounts on the system. The easiest way to do this is to log on as each of these users, one at a time (and pretend to be that user); and then use Ximian s Evolution e-mail client application to set that user up with an e-mail account.

If you re starting Evolution up for the first time, follow these steps:

  1. You get the first screen of the Setup Assistant, and you should click Forward button to create an account.

  2. In the Identity screen, enter your full name and e-mail address. (Evolution will accept only proper e-mail addresses here.)

  3. In the first of two Receiving Email screens, select POP from the options in the Server Type field, and enter the IP address of your machine in the Host field. (This is the IP address of the POP3 server.) Enter the username, and set the Authentication Type to Password.

  4. In the second Receiving Email screen, select Automatically check for new mail and specify the time interval between checks. Select Leave messages on server if you don t want messages deleted from the server after they ve been downloaded to the mailbox.

  5. In the next screen, Sending Email, change the Server Type to Sendmail (this selection is for delivery of mail messages by passing it to the Sendmail program on the local machine; the other option, SMTP, should be used for delivery of e-mails through a connection to a remote mail hub).

  6. In the next screen, Account Management, enter the name of the account (it can be any name, but we ll just use the e-mail address here). Enable Make this my default account.

  7. In the final screen, select a time zone. Then click Next, and then Finish, to complete the setup.

If you don t get the Setup Assistant when you launch Evolution, you can enter all this information via the tabs in the Tools>Settings>Mail Accounts dialog box instead.

Demonstrating the Sendmail MDA

To summarize, so far you ve done two things:

  • You ve set up the Sendmail application as a mail server, capable of listening for incoming mail messages on , and filtering those messages into the correct mailbox so that the intended recipient can read them.

  • You ve created some users, configured their mailboxes, and set up each user to use the Evolution application as a mail client (to enable them to send messages and view the messages they ve received).

In a moment, you can begin to test all this ”for example, by logging in as kapils, sending a message to markm, and then logging in as markm to check that the mail message safely arrived.

Starting the POP3 Service

Before you can use Evolution to send a message, you must start the POP3 service. Fedora Core 2 provides a package called dovecot that provides imap as well as POP3 services. The default settings for dovecot only enable Internet Message Access Protocol (IMAP) and IMAP Secure (IMAPS) services. You can also configure dovecot to enable and serve POP3 service. To do that, take the following steps:

  1. Open the dovecot configuration file /etc/dovecot.conf in your preferred text editor.

  2. Scroll down the configuration file until you can see the following configuration lines:

       # Protocols we want to be serving:     #  imap imaps pop3 pop3s     # protocols = imap imaps   

    As seen from the preceding configuration snippet, dovecot only enables imap and imaps services by default.

  3. To enable POP3 services on your system, uncomment the protocol line and add pop3 at the end of this line, as follows :

       protocols = imap imaps pop3   
  4. Save the file and start the dovecot service to implement the changes as follows:

       Service dovecot start   Starting Dovecot Imap:                                     [  OK  ] 

You can start the dovecot service to start imap or pop3 from the Service Configuration GUI (Main Menu>System Settings>Server Settings>Services). First, select the check box next to the dovecot entry in the list to automatically start the dovecot service on boot-up, and then click the Start. button at the top of the window to start the dovecot service.

  1. To test the pop3 service, connect to port 110 using telnet, as follows:

       telnet 110   Trying Connected to Escape character is '^]'. +OK dovecot ready. If you get a OK message at the end of the telnet session, that means the service is working OK. 
Sending Mails

Log on to one of your accounts (for example, kapil), and launch the Evolution application by selecting Main Menu>Internet>Evolution Email. Then select File>New>Mail Message, and write a mail message to another account on the system (see Figure 9-20).

click to expand
Figure 9-20

Click the Send button to send the message. You may be asked to provide your POP password; use the account s system password.

Receiving Mails

Now log out, and log in again as the user to whom you ve just sent the message (markm, in this example). Launch the Evolution application again for this user, and click the Send/Receive button at the top of the Evolution window. This button launches a process that contacts the mail server and does two things:

  • It queries the mail server for any new e-mail messages that have been sent to this account.

  • It passes any newly composed mail messages to the mail server, so they can be sent on to the intended recipients.

You ll be asked to provide your POP password; use the account s system password. (If you have problems here, go back and check that the ipop3 service is enabled.) Then you ll see a Send & Receive Mail dialog box.

Allow the Send mail process to complete (as shown by the progress bar in the figure), and then click Cancel All to cancel the remaining jobs. In the Inbox section of your Evolution window, you should now see the test message that was sent here from the first account, as shown in Figure 9-21.

click to expand
Figure 9-21

Feel free to experiment further with this, adding more mailbox addresses and hooking the Evolution application up to the Internet. You can also send and receive mail from Windows machines, using Microsoft Outlook. The same configuration settings should also suffice for Outlook; you ll need to set the server type to SMTP, which is the only option in Outlook for sending e-mails.

Beginning Fedora 2
Beginning Fedora 2
ISBN: 0764569961
EAN: 2147483647
Year: 2006
Pages: 170 © 2008-2017.
If you may any questions please contact us: