Book Image

Linux Email

Book Image

Linux Email

Overview of this book

Many businesses want to run their email servers on Linux for greater control and flexibility of corporate communications, but getting started can be complicated. The attractiveness of a free-to-use and robust email service running on Linux can be undermined by the apparent technical challenges involved. Some of the complexity arises from the fact that an email server consists of several components that must be installed and configured separately, then integrated together. This book gives you just what you need to know to set up and maintain an email server. Unlike other approaches that deal with one component at a time, this book delivers a step-by-step approach across all the server components, leaving you with a complete working email server for your small business network. Starting with a discussion on why you should even consider hosting your own email server, the book covers setting up the mail server. We then move on to look at providing web access, so that users can access their email out of the office. After this we look at the features you'll want to add to improve email productivity: virus protection, spam detection, and automatic email processing. Finally we look at an essential maintenance task: backups. Written by professional Linux administrators, the book is aimed at technically confident users and new and part-time system administrators. The emphasis is on simple, practical and reliable guidance. Based entirely on free, Open Source software, this book will show you how to set up and manage your email server easily.
Table of Contents (15 chapters)
Linux E-mail
Credits
About the Authors
About the Reviewers
Preface

E-mail and DNS


The Domain Name System (DNS) plays an important role in e-mailing. The DNS is used by both, e-mail clients and e-mail servers. Even if you do not intend to maintain your own DNS server, a thorough understanding of DNS's role in e-mailing is a necessity for the mail server operator. This section assumes that the reader has basic knowledge of how DNS works in general.

DNS record types used by e-mail applications

In many networking scenarios, only two DNS record types are used—the A record and PTR record. These map hostnames to IP addresses and IP addresses to hostnames respectively. These record types are also used for e-mail, but there is also a third DNS record type that is uniquely available for e-mail.

How does an SMTP server discover to which host a message for a certain domain should be delivered? The recipient domain is, not surprisingly, used as the key in one or more DNS lookups. The first lookup that is made is for the mail-specific MX record—the mail exchanger record type. The MX entry allows the DNS operator to specify the hostname or hostnames of servers that can receive mail for a certain domain. For example, MX records can be used to specify that messages to someone at example.com should be sent to mail.example.com. If the recipient domain does not have an MX record, an attempt is made to find an A record for the recipient domain. If the A record lookup succeeds, the mail will be delivered to the host. If both the MX and A lookups do not return any results, the message is deemed undeliverable and is returned to the sender.

There are two good reasons to having MX records:

  • Firstly, it might not be desirable to be forced to map the A record of a domain to the mail server. For example, Company Inc. with the WWW address http://www.example.com/ wants to allow visitors to use the shorterhttp://example.com/ URL, but does not want to run the web server application on the mail server (or vice versa).

  • The more important reason is that the result of an MX lookup not only contains a list of hostnames, but rather a list of (hostname, priority) tuples. The priority field is an integer describing the priority of the hostname within the list. The absolute magnitude of the priority number does not matter, but it is used in relation to the priority of any other hostnames to create an ordered list of hostnames to try when delivering a message. The list is in ascending order, so the hostname with the lowest priority number will be contacted first. If two hostnames have equal priority, they will be tried in random order.

Equal-priority MX records can be used as a very crude form of load balancing between two or more servers. This is also possible with A records that map to multiple IP addresses. A hierarchy of backup mail servers with different priorities can be set up for a domain using MX records that cannot be made to happen with A records. Let us look at a constructed example of an organization that uses a lot of mail servers.

Priority

Hostname

10

mx1.example.com

10

mx2.example.com

20

mx3.example.com

30

mx4.example.com

If this DNS configuration is set for the domain example.com, SMTP servers are expected to try to deliver messages for example.com to mx1.example.com or mx2.example.com first. If both connections fail, mx3.example.com should be tried, and if even that server does not respond in a timely way, mx4.example.com is the last resort. Should that fail too, the message is kept and delivery is retried at a later time.