Emails have always been an important part of our lives. We send emails through agents such as Gmail, Yahoo, etc. and we also get emails regarding different subjects from numerous other email clients. These email clients works on SMTP at port 25.
What is SMTP?
SMTP(Simple Mail Transfer Protocol ) is a Protocol which works on port 25.It is a mail delivery protocol and the application Sendmail works on that port and acts as Message Transport Agent(MTA).SMTP was designed for reliable mail transfer and delivery protocol. It works on TCP. It is all text protocol.
There are many functions of SMTP (Below Source taken from The Hackers Handbook)
• Client-to-server mail delivery: SMTP clients can route mail to a local mail server for delivery to a mailbox.
• Server-to-server mail delivery (mail relay): SMTP servers support store-and-forward of mail and server-to-server relay to ensure that mail is reliably delivered to its destination.
•Mail spooling/queuing: SMTP servers have facilities for spooling, “queuing,” and processing mail, contingent upon current resource constraints and server availability.
• Notification of delivery/non-delivery of mail (Delivery Status Notification): SMTP servers support Delivery Status Notifications (DSNs) to ensure that mail system failure or nonreceipt of mail is reported back to the originator of a mail message.
• Protocol-based error checking: SMTP servers and clients support a comprehensive set of error codes that are used in an SMTP exchange to ensure reliable mail delivery.
• Mail server redundancy (MX fallback): Mail servers can be configured in redundant server configurations that are accessed via DNS MX records; if a primary mail server fails, secondary or tertiary servers can store mail until the primary server becomes available.
• Content encapsulation (MIME): SMTP supports the encapsulation of various forms of content in a mail message (including binary content) via content standards such as Multipurpose Internet Mail
• Complex message routing: Mail message headers contain all the information (source/destination addressees, message IDs, return paths, etc.) to deliver a message to its destination or to ensure proper
receipt of error messages if the communication fails.
One more thing, “Server to server” mail delivery in the above point means that the SMTP is mail server to mail server means mails are routed to destination server and not the addressed user. Other services like POP3(Post Office Protocol version 3) and IMAP (Internet Mail access protocol) works under individual user mail delivery.
SMTP is a standard mail protocol for all emails .i.e, No matter what email you send on the internet, it always goes through SMTP server.Your message might go through one or more SMTP server depends on local or complex delivery. For an example:
I have an email “firstname.lastname@example.org” and I want to send an email to “email@example.com”. I wrote the email using Thunderbird for an example. The Thunderbird will take my message and send it to my ISP’s SMTP server or any near by SMTP server. The ISP SMTP server or any near by SMTP server which received my mail will see the Header and Destination Address or Recipient address and search through its records if it got the MX record for the domain name (gmail.com) which is the server that holds message for “firstname.lastname@example.org”. This is called Local Delivery. Since the domains are same.
A more complex scenario comes when the recipient I chose above is “email@example.com”. My Message would be received by the SMTP server and then it would check the domain which is responsible for holding yahoo.com emails. It would query the DNS server for yahoo.com MX(Mail Exchanger) record. Once SMTP server finds it, My email would be sent to that mail server.
We know the messages had been sent, but where have they gone? Well, the answer to this is,they are stored safely on the server which alice uses. But before she could eventually read the message, the message goes through the vigorous checking for SPAMS! Thats how the whole thing happens.
But then the question that may arrive on your mind is what exactly POP3 or IMAP used for because SMTP is doing everything here. Lets dive deeper!
Once the SMTP server sends the message and when they arrive on the Email storage Server , That’s exactly when these Email Clients came into picture. They take the messages from the server and then they separate them for the individual users.
Difference between IMAP and POP3?
Though both of them have the same purpose, They are different for different needs.
- They Both works on different ports. POP3 on 110 and IMAP on 143.
- POP3 is helpful when we only want to access the email in one device, IMAP is used when we have different devies.
- POP3 download copies from server and delete those emails from server. IMAP download copies from server and keep them,until you yourself delete them.
- POP3 stores emails locally so they can be views offline whereas for IMAP internet access is needed.
- In, POP3 structure, if the data is lost, there is no way for the recovery since it deletes the mails from the server too whereas in IMAP , if data is lost from the device it can be retrieved from the server.
The above article provides the overview of how actually all the protocols and services are used.
Most importantly the thing that we need to know is how to use these relay SMTP servers for spamming and phishing purposes. We will be doing that in the next article.
Stay Anonymous 🙂