How does a mail server work
Imagining the world without emails is virtually impossible. It is the only way by which people who are thousands of kilometers away can send as well as receive letters in a fraction of a second. For you to send an email, you should have an email client on your machine. The first modern type of email was sent in the year 1971.
An email is sent with the help of an email server. An email server is like a computer that serves the purpose of an electronic post office. It is capable of sending and receiving millions of emails simultaneously and consists of hardware as well as software components.
The functionality of an email server can be divided broadly into two processes: sending and receiving emails. The following two protocols oversee these processes.
- Sending email: Simple Mail Transfer Protocol (SMTP)
- Receiving email: Post Office Protocol (POP) / Internet Message Access Protocol (IMAP)
Check for registered clients
At first after an email is received the server checks whether it is from one of the registered email clients on the basis of which it either takes an incoming email or rejects it. An email is received by a server through port 25 if it is a SMPT protocol or through port 110 if it uses a POP3 protocol.
Separate the username and the site name
The server then separates the user name and the site name and in case the site name and the mail site to which it will be sent are the same then it is forwarded to a POP3 or IMAP server for the rest of the process to be performed.
Request DNS for IP address
In case the recipient email address is different from the sent address then the server will contact the domain name server or the DNS and request for the IP address of the mail client to which your mail is to be sent.
Store the mail in a database
The mail is then stored in a database on the server before it is forwarded to the receiving email id.
Resend and generate suitable error message
In case the SMTP server cannot locate the IP address of the recipient mail server, then the mail is queued and periodically sent to a fixed number of times before a message sending failed message is generated stating the reasons for its failure.
These are the basics of the working of an email server. Though various servers may have some small modifications but the basic job remains the same.
The primary job of an email server is to receive a message from the registered clients and then send it to any recipient address. Attachments are extra files that may not always be text, and hence, they need to be first encoded into text format and pasted in the main mail by the server itself before they are sent.
You can also check out list of mail server software.