Skip to main content

A sysadmin's guide to configuring an email server

The who, what, where, why, and how-to of email server configuration.
A sysadmin's guide to configuring an email server

Electronic mail has changed and developed over time. Statistics show that nearly 2,840,000 emails are sent every single second ( Our world revolves around this service that connects us.

One thing most people don’t understand is how email works, or more importantly, where it actually resides. This is knowledge that you will need in the future, so best to learn it now. How exactly does email work?

It’s actually pretty cool.

Note: Some of the things covered here, you may or may not be familiar with, but they will be covered in more detail in follow-up articles.

How email works

First, a mail user agent converts a message into text. Once converted, the mail user agent uses DNS to connect to the configured mail transport agent via the Simple Mail Transfer Protocol (SMTP). The sending mail agent then performs a mail exchanger record (MX record) lookup of the destination, connects to the destination mail transport agent, and finally delivers the email.

When delivery happens, the destination mail transport agent reviews the email and sends an acknowledgment that the message was received. The email is then delivered either to a virtual user or handled with a specific action (bounced, discarded, etc.)

For every email that is sent, a log entry is created in the mail client. Going over the basics of mail servers and its components is important to system administration. In this article, I’ll start with the basics and cover what you might need to know before configuring mail servers on Red Hat Enterprise Linux (RHEL)-based environments.

Email service components

As I mentioned earlier, there are three components of email services: mail user agents, mail transport agents, and mail delivery agents. Each component has its own purpose and a core reason for making email work in general.

I'll go over what happens when an email is sent once again, but this time in more detail.

Mail user agents

A mail user agent is essentially an email client. It helps the user to read the mail they receive and to write the email they want to send out. The mail user agent also actively receives and sends the email itself.

Mail transport agents

A mail transport agent is essentially an email service on a server. It is responsible for making sure that the mail is delivered from location to location. When you send an email, the mail server (often referred to as the SMTP server) processes the mail through the EHLO/HELO, which is a command it sends to identify itself when trying to connect to another mail server via SMTP. Once the receiving mail server is able to identify the destination mail server, SMTP relays the email to the destination server.

There are other parts of the SMTP process that are important to identify as well. Once the connection is made, commands are sent to the destination server in order for the email to be accessible by the mail user agent:

  1. The MAIL FROM command identifies the original sender of the email.
  2. The RCPT TO command gives the recipient’s address.
  3. The DATA command starts the process of sending the message body to the destination.
  4. A dot by itself on a separate line stops the message.
  5. The QUIT command closes the SMTP session and finalizes the process.

Mail delivery agents

A mail delivery agent is essentially an agent that delivers email on a local machine. There are two main protocols when mail user agents send email: the latest version of the Post Office Protocol (POP3) and the Internet Message Access Protocol (IMAP).

POP3 allows you to download copies of your email to your personal computer. These copies are usually unchanged, but it is common to unintentionally configure POP3 to delete the server copies after downloading the local copies. POP3 is best for those who prefer to have a backup of their email and don’t need to spend a lot of time online, but still need to read messages.

On the other hand, IMAP allows you to read email as it appears on the server. IMAP is best for those who have a lot of different people connecting from different sources, or an email account user who prefers to have their messages on a server rather than on their local machine.

Each protocol has its own ports that are usually available by default for your mail client. For POP3, the ports are 110 (default) and 995 (secure). For IMAP, they’re 143 (default) and 993 (secure).

Now that you're more familiar with the components and what they do, you can move on to the good stuff. System administrators live within their terminal, and this article covers configuring mail as such. In my past as a system administrator, setting up, configuring, and managing mail servers has been a helpful skill-set to have. I had a hard time remembering the services and what to install, so I used acronyms to remember commands, files, etc.

Learning mail services can be beneficial, whether in a work environment or a personal one. If you are ready to get started with installing an email server, I encourage you to read how to install and configure Postfix and how to install and configure Dovecot.

Topics:   Email   Networking   Linux  
Author’s photo

Gabrielle Stenzel

I currently work as a Cloud Support Supervisor for Acronis . I have worked with Linux and OpenSource tools for a decade, constantly wanting to make new resolutions for obstacles and always training others on improving systems as a systems administrator. More about me

Try Red Hat Enterprise Linux

Download it at no charge from the Red Hat Developer program.