How Mail Server Works. - ramanrupal/hello GitHub Wiki
Protocols Used in Email System
The email communication is done via three protocols in general. They are listed below.
- IMAP
- POP3
- SMTP
IMAP: INTERNET MESSAGE ACESS PROTOCOL. This protocol is used while receiving an email. When one uses IMAP, the emails will be present in the server and not get downloaded to the user’s mail box and deleted from the server. This helps to have less memory used in the local computer and server memory is increased.By default, the IMAP protocol works on two ports:
- Port 143 - this is the default IMAP non-encrypted port
- Port 993 - this is the port you need to use if you want to connect using IMAP securely
POP3: POST OFFICE PROTOCOL VERSION 3.This protocol is also used for incoming emails. The main difference with the both protocols is that POP downloads the entire email into the local computer and deletes the data on the server once it is downloaded. This is helpful in a server with less free memory. Current version of POP is POP3.By default, the POP3 protocol works on two ports:
- Port 110 - this is the default POP3 non-encrypted port
- Port 995 - this is the port you need to use if you want to connect using POP3 securely
SMTP: SIMPLE MAIL TRANSFER PROTOCOL.It is used to send mails to email servers. By default, the SMTP protocol works on three ports:
- Port 25 - this is the default SMTP non-encrypted port
- Port 2525 - this port is opened on all SiteGround servers in case port 25 is filtered (by your ISP for example) and you want to send non-encrypted emails with SMTP
- Port 465 - this is the port used if you want to send messages using SMTP securely
Terms Used:
MailServer: A mail server is a computer application. This application receives incoming emails from the local users (people within same domain) as well as remote senders and forwards outgoing email for delivery. A computer having such an application installed can also be called as a mail server.
DNS: The DNS stands for Domain Name System. The purpose of the DNS is to translate the domain names to the IP addresses and vice-versa. The DNS is used here to find out the mail server of the other side. This information is retrieved from the DNS and the email message is sent to the particular email address.
How Email Works:
First the sender needs to enter the email address of the recipient along with the message using an email application. This should be done at the local computers. Once it is finished and the “Send” button is clicked, the email will be going to the MTA (The Mail Transfer Agent). This communication is done via the SMTP protocol.
The next step is DNS lookup. The system sends a request to find out the corresponding MTA of the recipient. This will be done with the help of the MX record. In the DNS zone, for the receiver address’ domain, there will be an MX record (stands for Mail Exchanger record). This is a DNS resource record which specifies the mail server of a domain. So, after the DNS lookup, a response is given to the requested mail server with the IP address of the recipient’s mail server. This way the ‘to’ mail server is identified.
The next step is transferring the message between the mail servers. The SMTP protocol is used for this communication. Every message that comes into an email server and before the message itself come the connection it comes from is suspects.Email Server examine your ip to see if you are from bad neighbourhood. There are lot of databases that check and update list of bad ip addresses.If your ip was there then your connection will simply be rejected before you even have started the conversation.There are many spam filters.
Spam Checks:
- Check Your ip against real time data base.
- Check your headers are correct.
- Check your return address.
- Check your message for stop word patterns. Now our message is with the recipient mail server (MTA).
Let us assume our message crossed all the spam filters.Now, this message is transferred to the Mail Delivery Agent and then it is transferred to the recipient’s local computer. As we have seen earlier, two protocols can be used here. If we use POP3, then the whole email will be downloaded to the local computer and the copy at the server gets deleted. If the protocol used is IMAP, then the email message is stored in the mail server itself, but the user can easily manipulate the emails on the mail server as in the local computer. This is the difference when using both the protocols and this is how your email gets delivered. If some error occurred to send the email, the emails will be delayed. There is a mail queue in every mail server. These mails will be pending in the mail queue. The mail server will keep trying to resend the email. Once the email sending fails permanently, the mail server may send a bounce back email message to the sender’s email address.!