E-Mail and DNS server in Linux

Varsha Hunjan
5 min readDec 16, 2020

Hello readers! Hope you all are doing well. My today’s blog report will be about Email and DNS server in Linux. Hope you enjoy reading it!

DNS [Domain Name System]

To start with, let us check what DNS and Email exactly is. DNS is basically a decentralised & hierarchical naming system. This is basically used for services, computers, or other resources that might be connected to a private network or the internet. Various kinds of information are associated with the names which are related to/ assigned to all the different entities that participate in the network.

Fig 1. Representation of how DNS works

Email

We all might be aware of an Email (which is Electronic Mail). It is used for the exchange of formal messages, reaching out to people, etc. The most commonly used email platforms are Gmail, Outlook, Hotmail, etc.

Fig 2. Gmail (example of email)

DNS plays a very vital role when it comes to Emails. As we have discussed that DNS is used for naming, this service is required by both the email server as well as the client/user. Linux is an Operating System like any other Operating System. In most cases, the DNS servers that are used on a particular system are defined in a specific folder. To check this, one could check /etc/resolv.conf file and the information will be stored in there. Now, this file consists of at least one nameserver line. Each nameserver line in this document belongs to/defines a DNS server.

We are all aware that there are many users that are using email services on today’s date. To maintain and store the generated data, all the email providers are operating on the public internet itself. The top three email servers that are there on the internet today are Exim (over 55%), postfix(about over 30%), and SendMail(approx 4%). The three of these as well as QMail (which is a mail transfer agent) were originally designed for Unix like or Linux based OSs. However, today, there are a lot of ways to access and low-cost services available due to which anyone can set up their own email server.

Exim, postfix and Sendmail are all MTAs(Mail Transfer Agents).

Exim: It is a Mail Transfer Agent. Exim was mainly developed only for Unix based systems. The very first time it was written was in 1995. There is a GPLv2 license and Exim is licensed under the same. There was a survey conducted in 2019. In the same survey, it was noticed that Exim was accounted for almost 57 percent of the total online public email servers. The default version of Exim is Exim4 and it also comes as a default Mail Transfer Agent on all Debian-based GNU/Linux systems. It also includes Ubuntu.

Postfix: As discussed, Postfix also is a Mail Transfer Agent that was as well developed for Unix based systems. This was first released in 2019. This is under active development yet. The creators and contributors are working on it continuously. According to the survey that was conducted in 2019, it was examined that postfix accounts for almost 34% of all the online public mail servers that are there on the internet.

Sendmail: SendMail is a Mail Transfer Agent too. It was first released in 1983 and was yet again for Unix based systems. Sendmail is considered as the successor of the ARPANET program for delivering mails. This was developed as an alternative to the delivermail and was for BSD(Berkley Software Distribution) systems. According to the study of 2019, Sendmail accounted for only 4% of the total online public mail servers though it was once counted as 80 percent.

Fig 3. Representation of SMTP server configured on Ubuntu (a Linux distribution)

How does email work :
1. First, the email sender enters the email address of the person to whom he has send the email and type in the message that he has to send.
2. Once the user is done with this, the user clicks on send.
3. Here we have a component named MTA which is Mail Transfer Agent. In Linux, the MTAs that are used are Exim, Postfix, and SendMail.
4. The protocol used for triggering this/ sending this information to the MTAs is SMTP(Simple Mail Transfer Protocol).
5. In this step, the system checks whether to which DNS this request belongs.
6. This search is carried with the help of MX record and MX refers to Mail Exchanger record. There is a MX record that is present in the DNS zone for the receiver’s address’ domain which is the domain’s server.
7. After the last step, the message is forwarded to the recipient with the help of the IP address of the mail server of the receiver.
8. Now, the recipient side MTA holds the message. After that, the MTA transfers the received information to the MDA(Mail Delivery Agent) on the recipient’s end. The MDA then sends it to the local device.

There are two protocols that could be used at the receiver’s end:
1. POP3: If the POP3 protocol is used here, in that case, the copy of the email which is stored at the server-side will get deleted and only is downloaded on the local computer.
2. IMAP: However, on the other hand, when we use IMAP, the email is stored at the server end. This does not mean that the user can’t download it. In IMAP, users surely can download and manipulate the email.
We should also be aware of the errors. There is a queue that is present in every mail server. If by any chance an error occurs, then, the email is of course delayed and directly goes to the queue in the pending stage. As it remains in the queue as a pending request, the mail server tries to send the email again and again. However, once it fails after several attempts, the bounceback email will be sent to the sender.

That was all from my end today. Hope you all enjoyed it. See you soon. Till then, Take care!!

--

--