The following is an example of three rules used to control access to a Sendmail account. The first rejects messages from spam.com. The second rejects messages from lamer.com and displays an error message to that site. The third allows mail from the specific host user5.lamer.com, even though there is a rule that rejects mail from the site lamer.com.
For a more personal example of why you would bother to do this, I find that I get a lot of spam from the Hotmail domain, so I would just as soon reject it all. However, my wife uses a Hotmail account for her mail. If I did not allow her mail through, that would be a problem for me.
spam.com REJECT
lamer.com ERROR: "550 Mail from spammers is not accepted at this site."
user5.lamer.com OK
Open the /etc/access file, enter the rules of your choice, and then restart Sendmail so that your changes to the access file take effect. That can be done with
# service sendmail restart
or any of the other ways discussed in Chapter 11, "Automating Tasks."
Introducing Postfix
Sendmail has been the de facto MTA of choice for the Internet for a long time. At one point, it was the power behind 90% of the email traffic across the world, although it has now become largely superseded by worthier programs.
One of the more popular programs that have become available is Postfix, which was developed and is exclusively maintained by Wietse Venema. Designed to be a drop-in replacement for Sendmail, Postfix allows the system administrator to replace Sendmail without any detriment to the system.
Postfix was designed from the ground up to retain compatibility with Sendmail but to work in a more efficient fashion. Sendmail is notoriously system intensive when handling either large volumes of mail or large numbers of clients. One command pretty much handles everything, making Sendmail something of a monolith. On the other hand, Postfix works with several individual modules all working together, using modules only when needed.
Making the Switch
Postfix is easy to install and configure. The first thing to do is to make a backup of all your Sendmail information that you want to keep, just in case. After you have done this, you need to use yum to remove Sendmail and install Postfix.
After Postfix has been successfully installed, you can begin configuring it. The scripts for Postfix are all located in /etc/postfix and include
► install.cf — The script generated when Postfix is installed. This file lists the locations Postfix uses and can be a big help when working with the main.cf file.
► main.cf — The principal configuration script for Postfix. Within the remarks at the start of the script, you are advised to change only a couple of options at any time. This is sage advice, given that there are more than 300 possibilities!
► master.cf — The throttle control for Postfix. This script enables you to change settings for Postfix that directly affect the speed at which it works. Unless you have a reason to tinker with this file, leave it alone. Trust me: You will know when you need to make changes.
► postfix-script — The script used by Postfix as a wrapper. You cannot execute it directly; instead it is called by Postfix itself.
You can keep your original Sendmail aliases file for use with Postfix because it will not make much difference to it.
You will also require the services of system-switch-mail, which can also be installed by using yum.
After system-switch-mail has been successfully installed, switch to a root terminal and type the following:
# system-switch-mail
You are then greeted with a simple text screen, asking which MTA you want to use. Select Postfix and simply press Enter. After a few seconds, a new window appears, informing you that your MTA has been successfully switched. All you then need to do is ensure that Postfix is enabled in runlevel 5 by checking the service (system-config-services).
Further configuration of Postfix focuses on the main.cf file, which is extensively documented throughout the file using comments.
The beauty of Postfix is that it can be used in any situation from a single home user to a large corporation that has thousands of clients, even up to the ISP level. It can even be linked to MySQL for authentication purposes and virtual hosting.
Using Fetchmail to Retrieve Mail
SMTP is designed to work with systems that have a full-time connection to the Internet. What if you are on a dialup account? What if you have another system store your email for you and then you log in to pick it up once in a while? (Most users who are not setting up servers are in this situation.) In this case, you cannot easily receive email with SMTP, and you need to use a protocol, such as POP3 or IMAP, instead.
Remember when we said that some mail clients can include some MTA functionality? Microsoft Outlook and Outlook Express can be configured to use SMTP and, if you use a dialup connection, offer to start the connection and then use SMTP to send your mail. Therefore, a type of MTA functionality is included in those mail clients.
Unfortunately, many MUAs do not know anything about POP3 or IMAP. To eliminate that problem, you can use a program called Fetchmail to contact mail servers using POP3 or IMAP, download mail off the servers, and then inject those messages into the local MTA just as if they had come from a standard SMTP server. The following sections explain how to install, configure, and use the Fetchmail program.
Installing Fetchmail
Similar to other packages, Fetchmail can be installed with the yum install command. This command installs all files to their default locations. If, for whatever reason, you need to perform a custom installation, see Chapter 34, "Advanced Software Management," for more information on changing the default options for rpm.
You can get the latest version of Fetchmail at http://fetchmail.berlios.org. It is available in both source and RPM binary formats. The version of Fedora on the DVD accompanying this book provides a reasonably current version of Fetchmail and installs useful Fetchmail documentation in the /usr/share/doc/fetchmail directory. That directory includes an FAQ, features list, and Install documentation.
Configuring Fetchmail
After you have installed Fetchmail, you must create the file .fetchmailrc in your home directory, which provides the configuration for the Fetchmail program.