You are on page 1of 16

Chapter 28

Configuring Mail Server

E-mail is one of the most useful
features of the Internet. For an end user
using e-mail is a fast and economical way of
sending messages to any distance.
It is free and very easy to use. But
for an administrator configuring and
maintain an e-mail server is a challenging
job. Before going to the configuration details
let us see some basic facts about the e-mail
How e-mail is Sent and Received
Simple Mail Transport Protocol (SMTP) is the
protocol used to send mails form one network to another. E-
mail is sent in plain text using SMPT. A Mail Transport Agent
(MTA) is used to send and receive mails between networks.
It is the duty of the MTA to receive the mail from
the user and analyze the address and send it the correct
location and from there to the correct user. Some of the
famous MTAs are Sendmail, Qmail, Postfix.
The Mail User Agent ( MUA), or mail client
allows the user to read and compose mails. An end user will
be only familiar with this application. Commonly used mail
clients are Netscape Messenger, Outlook, pine, mutt, Mozilla
Mail, kmail and Evolution
The Mail Delivery Agent (MDA) is similar to
an MTA, but does not handle deliveries between
systems and does not provide an interface to the user
like an MUA. Example would be Procmail or
Spamassassin; both provide filtering service to MTA.
Sendmail is one of the most
famous MTAs used in the Internet. It is one
of the oldest and most powerful MTA exists.
The default configuration of the
sendmail will work for most basic
installations, and only minor changes are
needed to configure it for a basic server
Some shell scripts are available in
the Internet, which will help you to configure
the Sendmail easily.
Basic Sendmail Configuration
Sendmail configuration is handled by files in
the /etc/mail. Most of the configurations are
stored in a file file. The format of this
file is somewhat complicated.
To make the configuration of the sendmail
easier a file named is created. This
file is comparatively less complicated.
You can do the editing on file
and using a M4 macro processor you can create
a file from this.
Configure Masquerading
Sometimes you might want to have
sendmail masquerade as a host other than the
actual hostname of your system. Such a situation
could occur if you have a dial-up connection to
the Internet and your ISP handles all your mail for
In this case you will want Sendmail to
masquerade as the domain name of your ISP.
For example you may add a line in the file as bellow
Using Smart Hosts
If you don’t have a dedicated connection to the
Internet, you will probably want to have Sendmail send
your messages to your ISP’s mail server and let it
handle delivery for you.
Without a full time internet connection, you could
find it difficult to deliver messages to some locations. In
those situations, you can configure Sendmail to function
as a smart host by passing email on to another sender
rather that attempting to deliver the email directly. To
enable a smart host you can add a line with your file as follows:
define (`SMART_HOTS’, `’)
Setting message delivery intervals
By default Sendmail attempts to deliver
messages as soon as it receives them. If you
don’t have a full time connection with the Internet,
you may need Sendmail to hold all the messages
in a queue and attempt to deliver them at a
specific time intervals or at your prompt.
You can configure sendmail to do so by
adding the following lines with your
Define (`conDELIVERY_MODE’, `d’)dnl
# sendmail –bd –q30m
Building the file
After you have made all your changes to, you need to rebuild the file.
First, back up your old file:
You must run through the m4 macro
processor in order to generate a usable configuration
file. A command such as the following, is used to do this:
#m4 /etc/mail/ >
This command creates the from the, which you have modified accordingly.
Mail Relaying
By default, sendmail won’t relay mail that didn’t
originate from the local domain. This means that if a
Sendmail installation running at receives mails
intended for, and that mail didn’t originate
from, the mail will be rejected and won’t be
If you want to allow selected domain to relay
through you add an entry for the domain to the file
/etc/ If the file doesn’t exists, simply
create it in your favorite text editor and add a line
containing the name of the domain that you want to
allow to relay through you.
Sendmail will need to be restarted for this change
to take effect
Forwarding Email with aliases.
Aliases allow you to have an infinite
number of valid recipient address on your
system, without having to worry about creating
accounts or other support files for each address.
For example, most systems have
“postmaster” defined as a valid recipient, yet
don’t have an actual login account named
“postmaster”. Aliases are configures in the file
/etc/aliases. Here is an example on an alias
postmaster: root
This entry will forward any mail
received for “postmaster” to the root user.
By default, almost all the aliases listed in
the /etc/aliases file forwarded to root.
Any time you make a change to
root the /etc/aliases file, you will need to
rebuild the aliases database before that
change will take effect. This is done with
# newaliases.
Rejecting Email from specified
In Internet some sites are there which will
continuously send you large number of
unwanted mails. This is generally called spams.
You may need to reject mails coming
from these types of sites. You can use
/etc/access file to automatically reject mails from
certain sites.
After changing the /etc/access file you have
to restart sendmail as follows:
# service sendmail restart
Fetchmail Configuration
If you are using a dial-up connection to
connect with the Internet, you may need some
tools to retrieve mails from remote e-mail server
to your local server.
These tools will use POP3 or IMAP
protocol to retrieve mails from the remote mail
server and store it in your local server. Fetchmail
is a utility used to retrieve mails from a remote
mail server and store it in your local server. By
default Redhat linux comes with the Fetchmail
For configuring fetchmail the first thing
you want to do is create a .fetchmailrc file in your
home directory. This file will provide the
configuration for the Fetchmail. A sample entry in
the .fetchmailrc is given below:
poll "" proto pop3
user "m.mano" with pass “flower" is
"m.mano" here forcecr smtpaddress
You can have multiple entries for different users by
changing the server name, user name, password and
local user name. After creating the fetchmail file you can
invoke fetchmail for retrieving mails as follows:
#fetchmail –a