Everything you need to know about mail servers

Wondering what a mail server is? A mail server is a computer program or software that handles the sending, receiving, and storing email messages. It works with email clients, like Microsoft Outlook or Gmail, to facilitate the exchange of emails between users.

Updated: 20 Apr, 23 by Susith Nonis 7 Min

List of content you will read in this article:

In this article, we are going to talk about the concepts of mail transfer agent (MTA), mail user agent (MUA), mail submission agent (MSA), mail delivery agent or local delivery agent (MDA/LDA), mail retrieval agent (MRA), SMTP protocol, and many more. Keep along with us!

A mail transfer agent or message transfer agent (MTA) is the mail server, which receives mail from MUA or MSA and delivers the local mail to the local delivery agent and remote mail to the remote delivery agent.

The local delivery agent stores the mail in the local user’s mailbox. The remote delivery agent and remote delivery agent communicate with the remote mail server or MTA to deliver the mail.

MTA is not like a single delivery agent. It is the main engine, which could contain other email processes and queues. The mail transfer agent maintains the 25 port, and its main purpose is to process the incoming mail and relay it to the appropriate delivery agent.

All email clients are called mail user agents or MUA in email terminology. It can be software like Outlook, Thunderbird, Mailbird, etc. On the other hand, it can be a web client like Roundcube, SquirrelMail, etc.

The main function of MUA is to communicate with the mail server to send mail and to the POP/IMAP mail server for receiving mail. If the mail server or POP/IMAP mail server is configured with different ports and protocols, you must configure it as per the server's requirement.

Mail submission agent or MSA is a program inside the mail server package, which listens on port 587 (the standard secure SMTP port) and it is for receiving mail from the mail clients. 

The mail client is normally used to configure the outgoing server or SMTP address on the 25 port. However, this is not right! Because MSA is built for this purpose.

You should use MSA 587 port instead of the 25 port for sending mail because MSA talks with SMTP or extended SMTP with a mail client. It does not allow sending mail without authentication. That is why it is more secure. 

Many ISPs block the 25 ports to connect from the MUA for spam prediction. In that case, you have to connect MSA for email delivery. MSA receives mail from the MUA and delivers it to MTA for final delivery.

However, this is not mandatory to use MSA 587 port, but it is highly recommended. SMTP 25 port is for server-to-server communication, and MSA 587 port is for MUA to MTA communication.

A local delivery agent or LDA is a mail transport application built into the mail server software. Its main duty is to take mail from the MTA and deliver it to the local user’s mailbox. 

There are some widely used LDA like PROPmail and Maildrop, and Postfix. For example, on Postfix, the name of the local mail delivery agent is “local”, which reads dot-forward files and email alias files before delivery to the user’s mailbox.

Therefore, LDA takes mail from the MTA and delivers the mail to the user’s mailbox, and from there, the user can retrieve the mail using the POP/IMAP mail server.

A mail retrieval agent or MRA is a third-party application whose sole purpose is to pull or fetch email from the remote mail server. MRA is used in the office scenario if the organization's mail server is shut down after work hours.

Then the mail is stored at the high-speed mail server, and during work hours, MRA starts to download all the emails from the remote mail storage and the distributed user email to their mailboxes through the local delivery agents. MRA can retrieve a user’s email from multiple sources.

SMTP is the mail transport protocol which helps all mail servers communicate with each other. It sends mail from MUA to MTA and MTA to MTA for sending and receiving both.

SMTP's well-known port is 25 and is a combination of several commands. 

When you send a mail, the communication with the recipient server occurs with three steps:

  • They handshake with each other with SMTP HELO greetings.

When a server wants to send mail to another mail server, the first one becomes the SMTP client. It sends a HELO command to the SMTP server to identify itself and initiate the SMTP conversation.

The SMTP client's domain name or IP address is sent as an argument. If the SMTP server agrees to talk with the SMTP client, it sends the 250ok signal with its supported feature and list of authentication mechanisms.

  • The email transfer happens.

The client sends the MAIL FROM command. The server will reply with a 250-ok reply code if the sender's email address is accepted. 

  • After finishing the transfer, they close the connection.

The client sends the RCPT TO command, which specifies the recipient's email address. This command can be repeated multiple times to deliver a single email to multiple recipients. 

After the RCPT TO command, the client sends the DATA command to the server. The server will respond with a 354 reply code. The DATA command starts transferring the message content body, text, attachment, etc.

When all messages contained have been sent, a single dot (.) must be sent to stop the transfer. If the message is accepted for delivery, the SMTP server will respond with a 250 reply code and sends the message SKU number.

If you want to reset the connection, you can set the RSET command. Finally, you can close the connection with the QUIT command. In this way, the whole SMTP conversation occurs between two servers.

There are two major types of mail servers:

  • Incoming mail servers 

Such as POP3 (Post Office Protocol 3) and IMAP (Internet Message Access Protocol). POP3 downloads the incoming messages and stores them until the email client opens the mailbox. While IMAP helps the user to preview, delete and organize emails before transferring them.

  • Outgoing mail servers 

This enables the client’s system to communicate with SMTP to handle email delivery.

An On-premises mail server is a physical server located in an organization and should be managed and maintained by them.

A Cloud mail server is a virtual system hosted and maintained by an outside provider using cloud computing.

  • Security and data loss prevention
  • Cost
  • Archiving and storage
  • Compatibility

Here, we discussed the concept of a mail server, how it works, and every important information you need to understand the process. Feel free to drop your feedback, comments, and questions for us. Good luck!

People also read: 

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.