249
CHAPTER 10
Configuring Ubuntu Server
As a Mail Server
Sending and Receiving
Mail Easily
O
ne of the most common functions of a Linux system is to serve mail. Several
Linux- based mail server programs are available for this purpose. Several programs are
available to accomplish this task. In this chapter you will learn what is necessary to build
a solution to send and receive e-mail on a network. Because Ubuntu Server uses the
Postfix mail server by default to send mail to other networks, this chapter covers Postfix.
Different solutions are available to allow users to connect to their mailboxes to fetch mail.
One of the easiest to use of these solutions is
Qpopper
, so that is the solution of choice in
this chapter.
Understanding the Components of a Mail Solution
If you want to understand what is needed to build a mail server that can handle e-mail for
a complete network, you need to understand the three different agents that are used to
process Internet e-mail:
CHAPTER 10
N
CONFIGURING UBUNTU SERVER AS A MAIL SERVER
250
sMail transfer agent (MTA): This is the software that sends e-mail. This e-mail is
sent by the client that the user has used to compose and send the message. This
recipient MTA sends the e-mail to an MDA (defined next). Some well- known
MTAs are Postfix, Sendmail, and qmail. SMTP is an example of a protocol that can
be used by an MTA to deliver e-mail.
sMail delivery agent (MDA): The MDA works together with the MTA on the server
CHAPTER 10
N
CONFIGURING UBUNTU SERVER AS A MAIL SERVER
251
administrator to manage all individual programs that comprise the Postfix mail server.
The disadvantage is that, as an administrator, you need to know how all these separate
programs function. Wietse Venema originally developed Postfix as a mail server that
would be easier to administer and more secure than Sendmail. Because it is monolithic,
Sendmail is in general much harder to secure properly. Postfix also is a very rich mail
server that has many features.
N
Tip
You can find a complete list of all Postfix features and instructions on how to configure them at
dppl6++sss*lkopbet*knc+`k_qiajp]pekj*dpih
.
How Postfix works as a modular mail server becomes clearer from a discussion of
how mail traffic is handled by Postfix, so that is presented first. After that, you will learn
how to install and configure Postfix.
Handling Inbound and Outbound Mail
Generally speaking, Postfix can handle two kinds of mail: inbound mail and outbound
mail. The inbound mail that Postfix handles may be messages sent from a local user to
another local user or messages sent over the network to a local user. The outbound mail
that Postfix handles may be messages intended for a recipient on the same server as the
sender, messages intended for a recipient on a remote server, or undeliverable messages.
Processing Inbound Mail from a Local User to Another Local User
The following list explains how Postfix processes inbound mail, a graphical representa-
tion of which is shown in Figure 10-1:
1. When Postfix receives mail that is sent by another local user, Postfix uses the
lkop`nkl
command to place the mail in the maildrop queue, to ensure that the
“Tuning Postfix with Lookup Tables” later in this chapter)
s 2EFORMATSDATAINTHEHEADERACCORDINGTOALLRULESTHATAPPLY
4. The
_ha]jql
daemon copies the e-mail to the incoming queue and sends a mes-
sage to the queue manager (
micn
) to notify it that this mail has arrived.
Figure 10-1. Handling mail sent by a local user to another local user
CHAPTER 10
N
CONFIGURING UBUNTU SERVER AS A MAIL SERVER
253
Processing Inbound Mail Sent over the Network to a Local User
If incoming mail was received over the network, the process is slightly different from
that presented in the preceding section, mainly because Postfix doesn’t need to use the
lkop`nkl
and
le_gql
daemons to handle mail sent over the network to a local user. The
procedure is as follows (see Figure 10-2):
1. Postfix first uses the
oipl`
process to handle mail coming in over the network. This
process performs some basic checks on the e-mail before handing it over to the
_ha]jql
daemon.
2. The
_ha]jql
daemon performs the same tasks as when processing local mail (see
the local user. Before doing that, the local delivery service takes into account all
aliases and forwarding rules that apply to the mail.
4. The
hk_]h
daemon decides where to send the mail. It can, for example, send it to
the
lnk_i]eh
system, which analyzes the mail and puts it in the right folder.
Figure 10-3. Processing mail for a local user
Processing Outbound Mail Intended for a User on a Remote System
When the mail is intended for a user on a remote system, the procedure is as follows (see
Figure 10-4):
CHAPTER 10
N
CONFIGURING UBUNTU SERVER AS A MAIL SERVER
255
1. Again, the queue manager fetches the mail from the incoming queue and copies it
to the active queue as soon as it is empty.
2. The
pnere]h)nasnepa
daemon checks whether the mail is for a local user (see the
previous section) or a remote user (as in this example). If the mail is intended for
a remote user, all lookup tables that apply to that user are checked and then the
mail is passed to the queue manager.
3. The queue manager activates the SMTP service that delivers the e-mail to the
other server.
4. The
oipl`
process uses DNS to find the MTA for the target host and delivers it that
MTA.
handles the Internet connection for you.
sLocal only: Use this option if there is no network connection and mail is han-
dled for local users only.
Figure 10-5. To make configuring Postfix easier, the configuration program asks you
what kind of mail server you are configuring.
CHAPTER 10
N
CONFIGURING UBUNTU SERVER AS A MAIL SERVER
257
2. Enter the DNS domain name that should be used in the mail addresses of your
users (see Figure 10-6). For example, if you want the mail address of some user to
be
hej`]<at]ilha*_ki
, the name you enter here should be example.com.
Figure 10-6. Enter the DNS domain name for your mail server.
3. The Postfix files are copied to your server and the basic configuration is written.
Once completed, your Postfix mail server is ready for further configuration.
Configuring Postfix Further
The initial configuration that you set up when installing Postfix works fine, but it isn’t
very comprehensive. Therefore, right after you finish the initial configuration, I recom-
mend continuing the configuration by running
`lgc)na_kjbecqnalkopbet
. The following
procedure describes how to configure Postfix from that interface:
1. The first two steps are exactly the same as the first two steps of the installation pro-
gram. Accept the values that you entered earlier.
2. The third screen asks you what to do with mail for the user’s
lkopi]opan
,
nkkp
it does so only for its own IP address. If you are configuring this server as the local
mail server for your network, make sure that you enter the IP address and subnet
mask for that network in the screen shown in Figure 10-10. So, for example, if you
are on the local network
-5.*-24*-*,
, enter 192.168.1.0/24 here, to allow relaying
for every IP address that starts with
-5.*-24*-
.
6. If you want to put a limit on the maximum size of local mailboxes, enter that limit,
in bytes, in the screen shown in Figure 10-11. If you don’t need a limit, keep the
default value of 0.
CHAPTER 10
N
CONFIGURING UBUNTU SERVER AS A MAIL SERVER
260
Figure 10-10. Enter the IP address of your local network here to allow relaying.
Figure 10-11. If you want to limit mailboxes to a maximum size, enter that limit here,
specifying it in bytes.
7. If you want to add an extension to the name of local recipients, add that extension
in the screen shown in Figure 10-12. By default, a + sign is added. If you don’t need
such an extension, you can leave this field blank.